Skip to content
Snippets Groups Projects
Commit bd4da04d authored by JupyterHub User's avatar JupyterHub User
Browse files

Remove GIF animation in notebooks/V08...

parent 932d6404
No related branches found
No related tags found
1 merge request!1merge develop into master
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# <span style='color:OrangeRed'>V8 - Regelung im Zustandsraum</span> # <span style='color:OrangeRed'>V8 - Regelung im Zustandsraum</span>
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
from systheo2functions import * from systheo2functions import *
%matplotlib inline %matplotlib inline
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## <span style='color:Gray'>Beispiel #1 </span> ## <span style='color:Gray'>Beispiel #1 </span>
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Gegeben sei das System: Gegeben sei das System:
<br> $A$ = $\left[ \begin{array}{rrrr} <br> $A$ = $\left[ \begin{array}{rrrr}
1 & 1 \\ 1 & 1 \\
-2 & -1 \\ -2 & -1 \\
\end{array}\right] $ \end{array}\right] $
<br><br> $B$ = $\left[ \begin{array}{rrrr} <br><br> $B$ = $\left[ \begin{array}{rrrr}
0 \\ 0 \\
1 \\ 1 \\
\end{array}\right] $ \end{array}\right] $
<br><br> $C$ = $\left[ \begin{array}{rrrr} <br><br> $C$ = $\left[ \begin{array}{rrrr}
1 & 0 \\ 1 & 0 \\
\end{array}\right] $ \end{array}\right] $
<br><br> $D$ = $0$ . <br><br> $D$ = $0$ .
Zunächst prüfen wir die Steuerbarkeit des Systems über den Rang der Steuerbarkeitsmatrix: Zunächst prüfen wir die Steuerbarkeit des Systems über den Rang der Steuerbarkeitsmatrix:
<br><br> $S_c$ = $\left[ \begin{array}{rrrr} <br><br> $S_c$ = $\left[ \begin{array}{rrrr}
B & AB \\ B & AB \\
\end{array}\right] $ = $\left[ \begin{array}{rrrr} \end{array}\right] $ = $\left[ \begin{array}{rrrr}
0 & 1 \\ 0 & 1 \\
1 & -1 \\ 1 & -1 \\
\end{array}\right] {\Rightarrow} Rang~S_c = 2$ \end{array}\right] {\Rightarrow} Rang~S_c = 2$
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
A = np.array([[1,1], A = np.array([[1,1],
[-2,-1]]) [-2,-1]])
B = np.array([[0], B = np.array([[0],
[1]]) [1]])
C = np.array([1,0]) C = np.array([1,0])
D = np.array([0]) D = np.array([0])
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Prüfe die Steuerbarkeit mittels Rang-Funktion: Prüfe die Steuerbarkeit mittels Rang-Funktion:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
print('Steuerbarkeit des Systems:'); print('Steuerbarkeit des Systems:');
column1 = B column1 = B
column2 = np.matmul(A,B) column2 = np.matmul(A,B)
S_c = np.c_[column1,column2] S_c = np.c_[column1,column2]
print("S_c:\n"+str(S_c)+"\n") print("S_c:\n"+str(S_c)+"\n")
print_rank(S_c) print_rank(S_c)
``` ```
%% Output %% Output
Steuerbarkeit des Systems: Steuerbarkeit des Systems:
S_c: S_c:
[[ 0 1] [[ 0 1]
[ 1 -1]] [ 1 -1]]
Rang: 2 Rang: 2
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Wir sehen, wie erwartet, dass der Rang der Matrix 2 ergibt. Wir sehen, wie erwartet, dass der Rang der Matrix 2 ergibt.
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Im nächsten Schritt ermitteln wir die Eigenwerte des offenen Regelkreises: Im nächsten Schritt ermitteln wir die Eigenwerte des offenen Regelkreises:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
print_eig(A) print_eig(A)
``` ```
%% Output %% Output
Eigenwerte: Eigenwerte:
(-0+1j) (-0+1j)
(-0-1j) (-0-1j)
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Das offene System ist grenzstabil mit den Eigenwerten: $p_{1} = 0+j$ , $p_{2} = 0-j$ Das offene System ist grenzstabil mit den Eigenwerten: $p_{1} = 0+j$ , $p_{2} = 0-j$
<br><br>Gebe nun für den geschlossenen Regelkreis diese zwei Pole vor, sodass eine Verschiebung in die linke Halbebene erfolgt: <br><br>Gebe nun für den geschlossenen Regelkreis diese zwei Pole vor, sodass eine Verschiebung in die linke Halbebene erfolgt:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
print('Regler'); print('Regler');
pd = [-3+1j*3,-3-1j*3] pd = [-3+1j*3,-3-1j*3]
print("pd:"+str(pd)) print("pd:"+str(pd))
F = signal.place_poles(A, B, pd).gain_matrix F = signal.place_poles(A, B, pd).gain_matrix
print("F:"+str(F)) print("F:"+str(F))
``` ```
%% Output %% Output
Regler Regler
pd:[(-3+3j), (-3-3j)] pd:[(-3+3j), (-3-3j)]
F:[[23. 6.]] F:[[23. 6.]]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
So erhalten wir ein stabiles System. So erhalten wir ein stabiles System.
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Zur Veranschaulichung bilden wir zunächst dem folgenden Simulinkmodell nach. Wir fangen mit dem offenen Regelkreis <span style='color:Red'>A</span> an: Zur Veranschaulichung bilden wir zunächst dem folgenden Simulinkmodell nach. Wir fangen mit dem offenen Regelkreis <span style='color:Red'>A</span> an:
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<img src="bilder/v08_A.png" width="700"/> <img src="bilder/v08_A.png" width="700"/>
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Das System hat den Eingang Null, so erwarten wir an dieser Stelle im nächsten Schritt die homogene Lösung. Das System hat den Eingang Null, so erwarten wir an dieser Stelle im nächsten Schritt die homogene Lösung.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
#Regelkreis A #Regelkreis A
tini = 0 # Start time tini = 0 # Start time
tfinal = 10 # End time tfinal = 10 # End time
dt = 0.01 # Time Step dt = 0.01 # Time Step
nflows = 6 # Number of data flows in the schematic nflows = 6 # Number of data flows in the schematic
xo = np.array([[2], xo = np.array([[2],
[2]]) [2]])
C2 = np.array([[1, 0], C2 = np.array([[1, 0],
[0, 1]]) [0, 1]])
sc = Schema(tini,tfinal,dt,nflows) # Instance of the simulation schematic sc = Schema(tini,tfinal,dt,nflows) # Instance of the simulation schematic
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
<br> List of components: <br> List of components:
<br><br><span style='color:Orange'>Constant Function Definition:</span> <br><br><span style='color:Orange'>Constant Function Definition:</span>
<br><code>Constant(1.argument = Output_1, 2.argument = constant value)</code> <br><code>Constant(1.argument = Output_1, 2.argument = constant value)</code>
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
c1_1 = Constant(1,0); c1_1 = Constant(1,0);
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
<br><span style='color:Orange'>StateSpace Function Definition:</span> <br><span style='color:Orange'>StateSpace Function Definition:</span>
<br><code>StateSpace(1.argument = input_1, 2.argument= output_2 & output_3, 3.argument= A, 4.argument= B, 5.argument= initial conditions x0) <br><code>StateSpace(1.argument = input_1, 2.argument= output_2 & output_3, 3.argument= A, 4.argument= B, 5.argument= initial conditions x0)
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
c1_2 = StateSpace([1],[2,3],A,B,C2,D,xo); c1_2 = StateSpace([1],[2,3],A,B,C2,D,xo);
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
<br><span style='color:Orange'>Gain Function Definition:</span> <br><span style='color:Orange'>Gain Function Definition:</span>
<br><code>Gain(1.argument = input_2 & input_3, 2.argument = output_4, 3.argument= gain value) <br><code>Gain(1.argument = input_2 & input_3, 2.argument = output_4, 3.argument= gain value)
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
c1_3 = Gain([2,3],[4],-F); c1_3 = Gain([2,3],[4],-F);
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
sc.AddListComponents(np.array([c1_1,c1_2,c1_3])); sc.AddListComponents(np.array([c1_1,c1_2,c1_3]));
# Run the schematic and plot # Run the schematic and plot
out1 = sc.Run(np.array([2, 3, 4])); out1 = sc.Run(np.array([2, 3, 4]));
plt.plot(out1[0,:],out1[1,:],'r',out1[0,:],out1[2,:], 'b'); #Output Signal 1 & 2 plt.plot(out1[0,:],out1[1,:],'r',out1[0,:],out1[2,:], 'b'); #Output Signal 1 & 2
plt.grid() plt.grid()
plt.legend(['State-Space 1, x_{dot}','State-Space 1, y']) plt.legend(['State-Space 1, x_{dot}','State-Space 1, y'])
plt.show() plt.show()
``` ```
%% Output %% Output
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Wie beim grenzstabilen System zu erwarten, erkennen wir eine perfekte Oszillation. Wie beim grenzstabilen System zu erwarten, erkennen wir eine perfekte Oszillation.
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Hier betrachten wir den Verlauf unseres des Verstärkerelements F: Hier betrachten wir den Verlauf unseres des Verstärkerelements F:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
plt.plot(out1[0,:],out1[3,:],'g'); # Output_4 plt.plot(out1[0,:],out1[3,:],'g'); # Output_4
plt.grid() plt.grid()
plt.legend(['out gain F']) plt.legend(['out gain F'])
plt.show() plt.show()
``` ```
%% Output %% Output
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Im nächsten Schritt schließen wir den Regelkreis: Im nächsten Schritt schließen wir den Regelkreis:
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<img src="bilder/v08_B.png" width="700"/> <img src="bilder/v08_B.png" width="700"/>
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
#Regelkreis B #Regelkreis B
# Instance of the simulation schematic # Instance of the simulation schematic
sc2 = Schema(tini,tfinal,dt,nflows) sc2 = Schema(tini,tfinal,dt,nflows)
# List of components # List of components
c2_1 = Constant(1,0); #Just for reference for plotting graph, not being used here. c2_1 = Constant(1,0); #Just for reference for plotting graph, not being used here.
c2_2 = StateSpace([4],[2,3],A,B,C2,D,xo); c2_2 = StateSpace([4],[2,3],A,B,C2,D,xo);
c2_3 = Gain([2,3],[4],-F); c2_3 = Gain([2,3],[4],-F);
sc2.AddListComponents(np.array([c2_1,c2_2,c2_3])); sc2.AddListComponents(np.array([c2_1,c2_2,c2_3]));
# Run the schematic and plot # Run the schematic and plot
out2 = sc2.Run(np.array([2,3,4])); out2 = sc2.Run(np.array([2,3,4]));
plt.plot(out2[0,:],out2[1,:],'r',out2[0,:],out2[2,:], 'b'); #Output Signal 1 & 2 plt.plot(out2[0,:],out2[1,:],'r',out2[0,:],out2[2,:], 'b'); #Output Signal 1 & 2
plt.grid() plt.grid()
plt.legend(['State-Space 1, x_{dot}','State-Space 1, y']) plt.legend(['State-Space 1, x_{dot}','State-Space 1, y'])
plt.show() plt.show()
``` ```
%% Output %% Output
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Nun sehen wir, dass innerhalb von 2 Sekunden das System in den stabilen Zustand übergeht. Nun sehen wir, dass innerhalb von 2 Sekunden das System in den stabilen Zustand übergeht.
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Wieder betrachten wir den Verlauf am Verstärkerelement F: Wieder betrachten wir den Verlauf am Verstärkerelement F:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
plt.plot(out2[0,:],out2[3,:],'g'); # Output_4 plt.plot(out2[0,:],out2[3,:],'g'); # Output_4
plt.grid() plt.grid()
plt.legend(['out gain F']) plt.legend(['out gain F'])
plt.show() plt.show()
``` ```
%% Output %% Output
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## <span style='color:Gray'>Beispiel #2 </span> ## <span style='color:Gray'>Beispiel #2 </span>
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Gegeben sei das System aus <span style='color:Gray'>Beispiel #1</span>. Gegeben sei das System aus <span style='color:Gray'>Beispiel #1</span>.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
A = np.array([[1,1], A = np.array([[1,1],
[-2,-1]]) [-2,-1]])
B = np.array([[0], B = np.array([[0],
[1]]) [1]])
C = np.array([1,0]) C = np.array([1,0])
D = np.array([0]) D = np.array([0])
xo = np.array([[2], xo = np.array([[2],
[2]]) [2]])
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Nun möchten wir die Regelgröße fixieren. Im stationären Zustand soll nun die Regelgröße der Führungsgröße entsprechen. Hierfür ermitteln wir den Vorfilter $V$ mit: <br> $V$ = $[C(BF-A)^{-1}B]^{-1}$ Nun möchten wir die Regelgröße fixieren. Im stationären Zustand soll nun die Regelgröße der Führungsgröße entsprechen. Hierfür ermitteln wir den Vorfilter $V$ mit: <br> $V$ = $[C(BF-A)^{-1}B]^{-1}$
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
print('Steuerbarkeit des Systems:'); print('Steuerbarkeit des Systems:');
column1 = B column1 = B
column2 = np.matmul(A,B) column2 = np.matmul(A,B)
W = np.c_[column1,column2] W = np.c_[column1,column2]
print("W:\n"+str(W)+"\n") print("W:\n"+str(W)+"\n")
print_rank(W) print_rank(W)
``` ```
%% Output %% Output
Steuerbarkeit des Systems: Steuerbarkeit des Systems:
W: W:
[[ 0 1] [[ 0 1]
[ 1 -1]] [ 1 -1]]
Rang: 2 Rang: 2
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
print_eig(A) print_eig(A)
``` ```
%% Output %% Output
Eigenwerte: Eigenwerte:
(-0+1j) (-0+1j)
(-0-1j) (-0-1j)
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
print('Regler') print('Regler')
pd = [-3+1j*3,-3-1j*3] pd = [-3+1j*3,-3-1j*3]
print("pd:"+str(pd)) print("pd:"+str(pd))
F = control.place(A, B, pd) F = control.place(A, B, pd)
print("F:"+str(F)) print("F:"+str(F))
``` ```
%% Output %% Output
Regler Regler
pd:[(-3+3j), (-3-3j)] pd:[(-3+3j), (-3-3j)]
F:[[23. 6.]] F:[[23. 6.]]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Als Eingang wird in Simulink der Einheitssprung gewählt. Wir fügen nun den Vorfilter V als Gain Komponente ein: Als Eingang wird in Simulink der Einheitssprung gewählt. Wir fügen nun den Vorfilter V als Gain Komponente ein:
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<img src="bilder/v08_beispiel2.png" width="700"/> <img src="bilder/v08_beispiel2.png" width="700"/>
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
V = np.array([1/(np.matmul(C,np.matmul(inv(np.matmul(B,F)-A),B)))]) V = np.array([1/(np.matmul(C,np.matmul(inv(np.matmul(B,F)-A),B)))])
print("V = inv(C*inv(B*F-A)*B)") print("V = inv(C*inv(B*F-A)*B)")
print("V: "+str(V)) print("V: "+str(V))
``` ```
%% Output %% Output
V = inv(C*inv(B*F-A)*B) V = inv(C*inv(B*F-A)*B)
V: [[18.]] V: [[18.]]
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
nflows2 = 8 # Number of data flows in the schematic nflows2 = 8 # Number of data flows in the schematic
C2 = np.array([[1, 0], C2 = np.array([[1, 0],
[0, 1]]) [0, 1]])
sc3 = Schema(tini,tfinal,dt,nflows2) # Instance of the simulation schematic sc3 = Schema(tini,tfinal,dt,nflows2) # Instance of the simulation schematic
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
<br> List of components: <br> List of components:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
c3_1 = StepSource(1,0,1,1) c3_1 = StepSource(1,0,1,1)
c3_2 = Gain([1],[2],V) c3_2 = Gain([1],[2],V)
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
<br><span style='color:Orange'>Sum Function Definition:</span> <br><span style='color:Orange'>Sum Function Definition:</span>
<br><code>Sum(1.argument = input_2, 2.argument = input_3, 3.argument = output_4, 4.argument = first sign , 5.argument = second sign )</code> <br><code>Sum(1.argument = input_2, 2.argument = input_3, 3.argument = output_4, 4.argument = first sign , 5.argument = second sign )</code>
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
c3_3 = Sum(2,3,4,1,1) c3_3 = Sum(2,3,4,1,1)
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
c3_4 = StateSpace([4],[5,6],A,B,C2,D,xo) c3_4 = StateSpace([4],[5,6],A,B,C2,D,xo)
c3_5 = Gain([5,6],[3],-F) c3_5 = Gain([5,6],[3],-F)
c3_6 = Gain([5,6],[7],np.array([[0,1]])) c3_6 = Gain([5,6],[7],np.array([[0,1]]))
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
sc3.AddListComponents(np.array([c3_1,c3_2,c3_3,c3_4,c3_5,c3_6])); sc3.AddListComponents(np.array([c3_1,c3_2,c3_3,c3_4,c3_5,c3_6]));
#Run the schematic and plot #Run the schematic and plot
out3 = sc3.Run(np.array([3,5,6])); out3 = sc3.Run(np.array([3,5,6]));
plt.plot(out3[0,:],out3[2,:],'b'); plt.plot(out3[0,:],out3[2,:],'b');
plt.grid() plt.grid()
plt.legend(['Control Signal']) plt.legend(['Control Signal'])
plt.show() plt.show()
``` ```
%% Output %% Output
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Das Ergebnis zeigt, dass im stationären Zustand die Regelgröße der Führungsgröße entspricht Das Ergebnis zeigt, dass im stationären Zustand die Regelgröße der Führungsgröße entspricht
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
plt.plot(out3[0,:],out3[1,:],'g'); # Output_3 plt.plot(out3[0,:],out3[1,:],'g'); # Output_3
plt.legend(['out gain F']) plt.legend(['out gain F'])
plt.grid() plt.grid()
plt.show() plt.show()
``` ```
%% Output %% Output
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## <span style='color:Gray'>Beispiel #3 </span> ## <span style='color:Gray'>Beispiel #3 </span>
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Gegeben sei das bekannte System aus der Vorlesung: Gegeben sei das bekannte System aus der Vorlesung:
<br> $A$ = $\left[ \begin{array}{rrrr} <br> $A$ = $\left[ \begin{array}{rrrr}
-1 & 0 & 0 \\ -1 & 0 & 0 \\
1 & -2 & 0 \\ 1 & -2 & 0 \\
0 & 5 & 0 \\ 0 & 5 & 0 \\
\end{array}\right] $ \end{array}\right] $
<br><br> $B$ = $\left[ \begin{array}{rrrr} <br><br> $B$ = $\left[ \begin{array}{rrrr}
1 \\ 1 \\
0 \\ 0 \\
0 \\ 0 \\
\end{array}\right] $ \end{array}\right] $
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
A = np.array([[-1,0,0], A = np.array([[-1,0,0],
[1,-2,0], [1,-2,0],
[0, 5,0]]) [0, 5,0]])
B = np.array([[1], B = np.array([[1],
[0], [0],
[0]]) [0]])
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Zunächst ermitteln wir die Steuerbarkeitsmatrix: Zunächst ermitteln wir die Steuerbarkeitsmatrix:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
print('Steuerbarkeitsmatrix:'); print('Steuerbarkeitsmatrix:');
column1 = B column1 = B
column2 = np.matmul(A,B) column2 = np.matmul(A,B)
column3 = matmul_loop([A,A,B]) column3 = matmul_loop([A,A,B])
S_c = np.c_[column1,column2,column3] S_c = np.c_[column1,column2,column3]
print("S_c:\n"+str(S_c)+"\n") print("S_c:\n"+str(S_c)+"\n")
``` ```
%% Output %% Output
Steuerbarkeitsmatrix: Steuerbarkeitsmatrix:
S_c: S_c:
[[ 1 -1 1] [[ 1 -1 1]
[ 0 1 -3] [ 0 1 -3]
[ 0 0 5]] [ 0 0 5]]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Es wird lediglich die letzte Reihe (n=3) der inversen Steuerbarkeitsmatrix betrachtet ($s_{c_{n}}^T$): Es wird lediglich die letzte Reihe (n=3) der inversen Steuerbarkeitsmatrix betrachtet ($s_{c_{n}}^T$):
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
S_c_inv = np.linalg.pinv(S_c) S_c_inv = np.linalg.pinv(S_c)
print("S_c_inv:\n"+str(S_c_inv)) print("S_c_inv:\n"+str(S_c_inv))
s_c_n = S_c_inv[2,:] s_c_n = S_c_inv[2,:]
print("\ns_c_n:\n"+str(s_c_n)) print("\ns_c_n:\n"+str(s_c_n))
``` ```
%% Output %% Output
S_c_inv: S_c_inv:
[[ 1.00000000e+00 1.00000000e+00 4.00000000e-01] [[ 1.00000000e+00 1.00000000e+00 4.00000000e-01]
[-5.88324776e-18 1.00000000e+00 6.00000000e-01] [-5.88324776e-18 1.00000000e+00 6.00000000e-01]
[-4.57033997e-17 -1.17458319e-16 2.00000000e-01]] [-4.57033997e-17 -1.17458319e-16 2.00000000e-01]]
s_c_n: s_c_n:
[-4.57033997e-17 -1.17458319e-16 2.00000000e-01] [-4.57033997e-17 -1.17458319e-16 2.00000000e-01]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Da die Inverse ausgegeben werden kann, ist dies ein Beweis dass das System steuerbar ist, denn die Determinante ist ungleich Null. Da die Inverse ausgegeben werden kann, ist dies ein Beweis dass das System steuerbar ist, denn die Determinante ist ungleich Null.
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Nun wird die Polvorgabe durchgeführt: Nun wird die Polvorgabe durchgeführt:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
print('Polvorgabe') print('Polvorgabe')
print('p1 = -2, p2,3= -1+/-J') print('p1 = -2, p2,3= -1+/-J')
P = np.array([4,6,4,1]) P = np.array([4,6,4,1])
p1 = -2 p1 = -2
p2 = -1+1j p2 = -1+1j
p3 = -1-1j p3 = -1-1j
v1 = s_c_n v1 = s_c_n
v2 = np.matmul(s_c_n,A) v2 = np.matmul(s_c_n,A)
v3 = matmul_loop([s_c_n,A,A]) v3 = matmul_loop([s_c_n,A,A])
v4 = matmul_loop([s_c_n,A,A,A]) v4 = matmul_loop([s_c_n,A,A,A])
print("\nv1:\n"+str(v1)) print("\nv1:\n"+str(v1))
print("\nv2:\n"+str(v2)) print("\nv2:\n"+str(v2))
print("\nv3:\n"+str(v3)) print("\nv3:\n"+str(v3))
print("\nv4:\n"+str(v4)) print("\nv4:\n"+str(v4))
``` ```
%% Output %% Output
Polvorgabe Polvorgabe
p1 = -2, p2,3= -1+/-J p1 = -2, p2,3= -1+/-J
v1: v1:
[-4.57033997e-17 -1.17458319e-16 2.00000000e-01] [-4.57033997e-17 -1.17458319e-16 2.00000000e-01]
v2: v2:
[-7.17549193e-17 1.00000000e+00 0.00000000e+00] [-7.17549193e-17 1.00000000e+00 0.00000000e+00]
v3: v3:
[ 1. -2. 0.] [ 1. -2. 0.]
v4: v4:
[-3. 4. 0.] [-3. 4. 0.]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Nun wird die Polvorgabe durchgeführt: Nun wird die Polvorgabe durchgeführt:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
F2 = signal.place_poles(A, B, np.array([p1, p2, p3])).gain_matrix F2 = signal.place_poles(A, B, np.array([p1, p2, p3])).gain_matrix
print("F2: "+str(F2))#Nach Polvergabe ist F2 = F print("F2: "+str(F2))#Nach Polvergabe ist F2 = F
``` ```
%% Output %% Output
F2: [[1. 2. 0.8]] F2: [[1. 2. 0.8]]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
$f^T = p_{0}s_{c_{n}}^{T} + p_{1}s_{c_{n}}^{T}A + p_{1}s_{c_{n}}^{T}A^2 + p_{1}s_{c_{n}}^{T}A^3$ $f^T = p_{0}s_{c_{n}}^{T} + p_{1}s_{c_{n}}^{T}A + p_{1}s_{c_{n}}^{T}A^2 + p_{1}s_{c_{n}}^{T}A^3$
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
F = [P[0]*v1+P[1]*v2+P[2]*v3+P[3]*v4] #Rückführfaktor F = [P[0]*v1+P[1]*v2+P[2]*v3+P[3]*v4] #Rückführfaktor
print("F: "+str(F)) print("F: "+str(F))
``` ```
%% Output %% Output
F: [array([1. , 2. , 0.8])] F: [array([1. , 2. , 0.8])]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Die Polvorgabe erfolgte durch die Wahl der charakteristischen Gleichung: Die Polvorgabe erfolgte durch die Wahl der charakteristischen Gleichung:
<br> $P(s) = 4 + 6s + 4s^2 + s^3 $ <br> $P(s) = 4 + 6s + 4s^2 + s^3 $
<br> Damit erhält man schließlich den Rückführvektor: <br> Damit erhält man schließlich den Rückführvektor:
<br> $f^T$ = $4 \left[ \begin{array}{rrrr} <br> $f^T$ = $4 \left[ \begin{array}{rrrr}
0 & 0 & \frac{1}{5} \\ 0 & 0 & \frac{1}{5} \\
\end{array}\right] \end{array}\right]
+ 6 \left[ \begin{array}{rrrr} + 6 \left[ \begin{array}{rrrr}
0 & 1 & 0 \\ 0 & 1 & 0 \\
\end{array}\right] \end{array}\right]
+ 4 \left[ \begin{array}{rrrr} + 4 \left[ \begin{array}{rrrr}
1 & -2 & 0 \\ 1 & -2 & 0 \\
\end{array}\right] \end{array}\right]
+ 6 \left[ \begin{array}{rrrr} + 6 \left[ \begin{array}{rrrr}
-3 & 4 & 0 \\ -3 & 4 & 0 \\
\end{array}\right]$ \end{array}\right]$
<br><br> $f^T$ = $6 \left[ \begin{array}{rrrr} <br><br> $f^T$ = $6 \left[ \begin{array}{rrrr}
1 & 2 & \frac{4}{5} \\ 1 & 2 & \frac{4}{5} \\
\end{array}\right]$ \end{array}\right]$
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## <span style='color:Gray'>Beispiel #4 </span> ## <span style='color:Gray'>Beispiel #4 </span>
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Gegeben sei das System: Gegeben sei das System:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
A1 = np.array([[1,0], A1 = np.array([[1,0],
[0,-1]]) [0,-1]])
B1 = np.array([[1], B1 = np.array([[1],
[0]]) [0]])
C2 = np.array([[1,0], C2 = np.array([[1,0],
[0,1]]) [0,1]])
D1 = np.array([[0], D1 = np.array([[0],
[0]]) [0]])
F = np.array([[4,0]]) F = np.array([[4,0]])
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Das offene System ist instabil und nicht steuerbar! Das offene System ist instabil und nicht steuerbar!
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<img src="bilder/v08_A.png" width="700"/> <img src="bilder/v08_A.png" width="700"/>
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
tini = 0 # Start time tini = 0 # Start time
tfinal = 10 # End time tfinal = 10 # End time
dt = 0.01 # Time Step dt = 0.01 # Time Step
nflows = 5 nflows = 5
xo = np.array([[2],[2]]) xo = np.array([[2],[2]])
sc4 = Schema(tini,tfinal,dt,nflows) # Instance of the simulation schematic sc4 = Schema(tini,tfinal,dt,nflows) # Instance of the simulation schematic
c4_1 = Constant(1,0); c4_1 = Constant(1,0);
c4_2 = StateSpace([1],[2,3],A1,B1,C2,D1,xo); c4_2 = StateSpace([1],[2,3],A1,B1,C2,D1,xo);
c4_3 = Gain([2,3],[4],-1*F); c4_3 = Gain([2,3],[4],-1*F);
sc4.AddListComponents(np.array([c4_1,c4_2,c4_3])); sc4.AddListComponents(np.array([c4_1,c4_2,c4_3]));
#Run the schematic and plot: #Run the schematic and plot:
out4 = sc4.Run(np.array([1, 2, 4])); out4 = sc4.Run(np.array([1, 2, 4]));
plt.plot(out4[0,:],out4[1,:],'blue',out4[0,:],out4[2,:],'red') plt.plot(out4[0,:],out4[1,:],'blue',out4[0,:],out4[2,:],'red')
plt.grid() plt.grid()
plt.legend(['State-Space 1, x_{dot}','State-Space 1, y']) plt.legend(['State-Space 1, x_{dot}','State-Space 1, y'])
plt.show() plt.show()
``` ```
%% Output %% Output
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
plt.plot(out4[0,:],out4[3,:],'g')# Output_4 plt.plot(out4[0,:],out4[3,:],'g')# Output_4
plt.legend(['out gain F']) plt.legend(['out gain F'])
plt.grid() plt.grid()
plt.show() plt.show()
``` ```
%% Output %% Output
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Der erste Pol kann also mittels $F_1$ verschoben werden, sodass das System stabil wird! Der erste Pol kann also mittels $F_1$ verschoben werden, sodass das System stabil wird!
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<img src="bilder/v08_B.png" width="700"/> <img src="bilder/v08_B.png" width="700"/>
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
sc5 = Schema(tini,tfinal,dt,nflows) # Instance of the simulation schematic sc5 = Schema(tini,tfinal,dt,nflows) # Instance of the simulation schematic
c5_1 = Constant(1,0); c5_1 = Constant(1,0);
c5_2 = StateSpace([4],[2,3],A1,B1,C2,np.array([0]),xo); c5_2 = StateSpace([4],[2,3],A1,B1,C2,np.array([0]),xo);
c5_3 = Gain([2,3],[4],-1*F); c5_3 = Gain([2,3],[4],-1*F);
sc5.AddListComponents(np.array([c5_1,c5_2,c5_3])); sc5.AddListComponents(np.array([c5_1,c5_2,c5_3]));
# Run the schematic and plot # Run the schematic and plot
out5 = sc5.Run(np.array([2,3,4])) out5 = sc5.Run(np.array([2,3,4]))
plt.plot(out5[0,:],out5[1,:],'b', out5[0,:],out5[2,:],'r'); #Output Signal 1 & 2 plt.plot(out5[0,:],out5[1,:],'b', out5[0,:],out5[2,:],'r'); #Output Signal 1 & 2
plt.legend(['State-Space 1, x_{dot}','State-Space 1, y']) plt.legend(['State-Space 1, x_{dot}','State-Space 1, y'])
plt.grid() plt.grid()
plt.show() plt.show()
``` ```
%% Output %% Output
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
plt.plot(out5[0,:],out5[3,:],'g') # Output_4 plt.plot(out5[0,:],out5[3,:],'g') # Output_4
plt.legend(['out gain F']) plt.legend(['out gain F'])
plt.grid() plt.grid()
plt.show() plt.show()
``` ```
%% Output %% Output
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Das System wurde durch Polplatzierung stabilisiert. Das System wurde durch Polplatzierung stabilisiert.
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## <span style='color:Gray'>Beispiel #5 </span> ## <span style='color:Gray'>Beispiel #5 </span>
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Gegeben sei das System aus <span style='color:Gray'>Beispiel #1</span>. Gegeben sei das System aus <span style='color:Gray'>Beispiel #1</span>.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
A = np.array([[1,1], A = np.array([[1,1],
[-2,-1]]) [-2,-1]])
B = np.array([[0], B = np.array([[0],
[1]]) [1]])
C = np.array([1,0]) C = np.array([1,0])
D = np.array([0]) D = np.array([0])
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Das charakteristische Polynom ist gegeben: Das charakteristische Polynom ist gegeben:
<br><br> $P(s)$ = $s^2$ + 2$\xi$$\omega_0$ + $\omega_r$ $mit$ $\xi = 0,7$ $und$ $\omega_r=2$ <br><br> $P(s)$ = $s^2$ + 2$\xi$$\omega_0$ + $\omega_r$ $mit$ $\xi = 0,7$ $und$ $\omega_r=2$
Da $\xi = 0.7$ erhalten wir komplexe Pole. Mit $\omega_r$ wir die Geschwindigkeit des Systems einstellen. Die natürliche Frequenz $\omega_0$ wird mit jeder Iteration um $2$ erhöht. Da $\xi = 0.7$ erhalten wir komplexe Pole. Mit $\omega_r$ wir die Geschwindigkeit des Systems einstellen. Die natürliche Frequenz $\omega_0$ wird mit jeder Iteration um $2$ erhöht.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
print('Steuerbarkeit des Systems:') print('Steuerbarkeit des Systems:')
column1 = B column1 = B
column2 = np.matmul(A,B) column2 = np.matmul(A,B)
S_c = np.c_[column1,column2] S_c = np.c_[column1,column2]
print("S_c:\n"+str(S_c)) print("S_c:\n"+str(S_c))
print_rank(S_c) print_rank(S_c)
print('\nEigenwerte A:'); print('\nEigenwerte A:');
print_eig(A) print_eig(A)
print('\nRegler:'); print('\nRegler:');
csi = 0.7; csi = 0.7;
omr = 2; omr = 2;
u = np.zeros((10,100)) u = np.zeros((10,100))
y = np.zeros((10,100)) y = np.zeros((10,100))
for i in range(1,10): for i in range(1,10):
omo = i*omr omo = i*omr
pd = np.array([-csi*omo+1j*omo*sqrt(1-csi*csi),-csi*omo-1j*omo*sqrt(1-csi*csi)]) pd = np.array([-csi*omo+1j*omo*sqrt(1-csi*csi),-csi*omo-1j*omo*sqrt(1-csi*csi)])
F = signal.place_poles(A,B,pd).gain_matrix F = signal.place_poles(A,B,pd).gain_matrix
xini = [[2], xini = [[2],
[2]] [2]]
Acl = A-np.matmul(B,F) Acl = A-np.matmul(B,F)
deltat=0.01 deltat=0.01
for q in range(1,100): for q in range(1,100):
y[i][q] = matmul_loop([C,linalg.expm(Acl*deltat*q),xini]) y[i][q] = matmul_loop([C,linalg.expm(Acl*deltat*q),xini])
u[i][q] = matmul_loop([-1*F,linalg.expm(Acl*deltat*q),xini]) u[i][q] = matmul_loop([-1*F,linalg.expm(Acl*deltat*q),xini])
%matplotlib inline %matplotlib inline
print("\ninput signal u") print("\ninput signal u")
for i in range(1,10): for i in range(1,10):
plt.plot(np.array(range(1, 101))*deltat,u[i,:]); plt.plot(np.array(range(1, 101))*deltat,u[i,:]);
plt.grid() plt.grid()
plt.show() plt.show()
print("\noutput signal y") print("\noutput signal y")
for i in range(1,10): for i in range(1,10):
plt.plot(np.array(range(1, 101))*deltat,y[i,:]); plt.plot(np.array(range(1, 101))*deltat,y[i,:]);
plt.grid() plt.grid()
plt.show() plt.show()
``` ```
%% Output %% Output
Steuerbarkeit des Systems: Steuerbarkeit des Systems:
S_c: S_c:
[[ 0 1] [[ 0 1]
[ 1 -1]] [ 1 -1]]
Rang: 2 Rang: 2
Eigenwerte A: Eigenwerte A:
Eigenwerte: Eigenwerte:
(-0+1j) (-0+1j)
(-0-1j) (-0-1j)
Regler: Regler:
input signal u input signal u
output signal y output signal y
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## <span style='color:Gray'>Beispiel #6 </span> ## <span style='color:Gray'>Beispiel #6 </span>
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Gegeben sei das System aus <span style='color:Gray'>Beispiel #1</span>. Es gilt $T_s=0.1$. Gegeben sei das System aus <span style='color:Gray'>Beispiel #1</span>. Es gilt $T_s=0.1$.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
A = np.array([[1,1], A = np.array([[1,1],
[-2,-1]]) [-2,-1]])
B = np.array([[0], B = np.array([[0],
[1]]) [1]])
C = np.array([1,0]) C = np.array([1,0])
D = np.array([0]) D = np.array([0])
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Prüfe die Steuerbarkeit mittels Rang-Funktion: Prüfe die Steuerbarkeit mittels Rang-Funktion:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
print('Steuerbarkeit des Systems:') print('Steuerbarkeit des Systems:')
column1 = B column1 = B
column2 = np.matmul(A,B) column2 = np.matmul(A,B)
S_c = np.c_[column1,column2] S_c = np.c_[column1,column2]
print("S_c:\n"+str(S_c)) print("S_c:\n"+str(S_c))
print_rank(S_c) print_rank(S_c)
``` ```
%% Output %% Output
Steuerbarkeit des Systems: Steuerbarkeit des Systems:
S_c: S_c:
[[ 0 1] [[ 0 1]
[ 1 -1]] [ 1 -1]]
Rang: 2 Rang: 2
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Ermittle Eigenwerte für den offenen Regelkreis: Ermittle Eigenwerte für den offenen Regelkreis:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
print('\nEigenwerte A:'); print('\nEigenwerte A:');
print_eig(A) print_eig(A)
``` ```
%% Output %% Output
Eigenwerte A: Eigenwerte A:
Eigenwerte: Eigenwerte:
(-0+1j) (-0+1j)
(-0-1j) (-0-1j)
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Gebe nun für den geschlossenen Regelkreis diese zwei Pole vor: Gebe nun für den geschlossenen Regelkreis diese zwei Pole vor:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
print('Regler:'); print('Regler:');
pd = np.array([-3+3j,-3-3j]) pd = np.array([-3+3j,-3-3j])
print("Polstellen: "+str(pd)) print("Polstellen: "+str(pd))
F = signal.place_poles(A,B,pd).gain_matrix F = signal.place_poles(A,B,pd).gain_matrix
print("F: "+str(F)) print("F: "+str(F))
``` ```
%% Output %% Output
Regler: Regler:
Polstellen: [-3.+3.j -3.-3.j] Polstellen: [-3.+3.j -3.-3.j]
F: [[23. 6.]] F: [[23. 6.]]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Abtast: Abtast:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
Ts = 0.1 Ts = 0.1
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Die Regelstrecke soll diskretisiert werden. So erhalten wir <code>A_d</code> und <code>B_d</code>: Die Regelstrecke soll diskretisiert werden. So erhalten wir <code>A_d</code> und <code>B_d</code>:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
Ad = linalg.expm(A*Ts) Ad = linalg.expm(A*Ts)
print("Ad:\n"+str(Ad)) print("Ad:\n"+str(Ad))
einh = np.array([[1,0], einh = np.array([[1,0],
[0,1]]) [0,1]])
Bd = matmul_loop([(Ad-einh),inv(A),B]) Bd = matmul_loop([(Ad-einh),inv(A),B])
print("\nBd:\n"+str(Bd)) print("\nBd:\n"+str(Bd))
``` ```
%% Output %% Output
Ad: Ad:
[[ 1.09483758 0.09983342] [[ 1.09483758 0.09983342]
[-0.19966683 0.89517075]] [-0.19966683 0.89517075]]
Bd: Bd:
[[0.00499583] [[0.00499583]
[0.09483758]] [0.09483758]]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Die korrespondierenden (beliebigen) Pole im zeitdiskreten System lauten: Die korrespondierenden (beliebigen) Pole im zeitdiskreten System lauten:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
pdd = np.array(exp(pd*Ts)) pdd = np.array(exp(pd*Ts))
print("\npdd: "+str(pdd)) print("\npdd: "+str(pdd))
``` ```
%% Output %% Output
pdd: [0.70773068+0.21892675j 0.70773068-0.21892675j] pdd: [0.70773068+0.21892675j 0.70773068-0.21892675j]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
In diesem Fall wird dem Regler das diskrete Signal zugeführt: In diesem Fall wird dem Regler das diskrete Signal zugeführt:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
Fd = signal.place_poles(Ad,Bd,pdd).gain_matrix Fd = signal.place_poles(Ad,Bd,pdd).gain_matrix
print("Fd: "+str(Fd)) print("Fd: "+str(Fd))
``` ```
%% Output %% Output
Fd: [[17.48338056 5.13723447]] Fd: [[17.48338056 5.13723447]]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Vergleicht man die Werte aus <span style='color:Gray'>Beispiel #1</span>, mit den Werten des diskretisierten Systems, ist Vergleicht man die Werte aus <span style='color:Gray'>Beispiel #1</span>, mit den Werten des diskretisierten Systems, ist
eine Abweichung zu erkennen, da $f^T$=[23 6] zuvor galt! eine Abweichung zu erkennen, da $f^T$=[23 6] zuvor galt!
<br><br>Veranschaulichung durch Simulink: <br><br>Veranschaulichung durch Simulink:
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<img src="bilder/v08_beispiel6.png" width="700"/> <img src="bilder/v08_beispiel6.png" width="700"/>
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# Instance of the simulation schematic # Instance of the simulation schematic
nflowsd = 12 nflowsd = 12
tfinal = 4 tfinal = 4
dt = 0.01 dt = 0.01
C2 = np.array([[1,0], C2 = np.array([[1,0],
[0,1]]) [0,1]])
sc6 = Schema(tini,tfinal,dt,nflowsd); sc6 = Schema(tini,tfinal,dt,nflowsd);
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
<br> List of components: <br> List of components:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
c6_1 = StateSpace([1],[2,3],A,B,C2,D,xo); c6_1 = StateSpace([1],[2,3],A,B,C2,D,xo);
c6_2 = Gain([2,3],[4],-1*Fd); c6_2 = Gain([2,3],[4],-1*Fd);
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
<br><span style='color:Orange'>Zero order hold (ZOH) Function Definition:</span> <br><span style='color:Orange'>Zero order hold (ZOH) Function Definition:</span>
<br><code>ZOH(1.argument = input_4, 2.argument = output_1, 3.argument = sample time )</code> <br><code>ZOH(1.argument = input_4, 2.argument = output_1, 3.argument = sample time )</code>
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
c6_3 = ZOH(4,1,Ts); c6_3 = ZOH(4,1,Ts);
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
c6_4 = StateSpace([5],[6,7],A,B,C2,D,xo); c6_4 = StateSpace([5],[6,7],A,B,C2,D,xo);
c6_5 = Gain([6,7],[8],-1*F); c6_5 = Gain([6,7],[8],-1*F);
c6_6 = ZOH(8,5,Ts); c6_6 = ZOH(8,5,Ts);
c6_7 = StateSpace([9],[10,11],A,B,C2,D,xo); c6_7 = StateSpace([9],[10,11],A,B,C2,D,xo);
c6_8 = Gain([10,11],[9],-F); c6_8 = Gain([10,11],[9],-F);
#c6{9} = Gain([2 3],12,[0 1]); #c6{9} = Gain([2 3],12,[0 1]);
#c6{10} = Gain([6 7],13,[0 1]); #c6{10} = Gain([6 7],13,[0 1]);
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
sc6.AddListComponents(np.array([c6_1,c6_2,c6_3,c6_4,c6_5,c6_6,c6_7,c6_8])) sc6.AddListComponents(np.array([c6_1,c6_2,c6_3,c6_4,c6_5,c6_6,c6_7,c6_8]))
out6 = sc6.Run(np.array([2,6,10])) out6 = sc6.Run(np.array([2,6,10]))
plt.plot(out6[0,:],out6[1,:],'r', out6[0,:],out6[2,:],'b'); plt.plot(out6[0,:],out6[1,:],'r', out6[0,:],out6[2,:],'b');
plt.legend(['discrete out','continuous out']) plt.legend(['discrete out','continuous out'])
plt.grid() plt.grid()
plt.show() plt.show()
``` ```
%% Output %% Output
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Je kleiner die Abtastzeit gewählt wird, desto kleiner wäre auch die Abweichung. Je kleiner die Abtastzeit gewählt wird, desto kleiner wäre auch die Abweichung.
Höhere Abtastzeiten bedeuten jedoch einen höheren Rechenaufwand! Höhere Abtastzeiten bedeuten jedoch einen höheren Rechenaufwand!
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
Ts2 = 0.01; Ts2 = 0.01;
sc7 = Schema(tini,tfinal,dt,nflowsd); sc7 = Schema(tini,tfinal,dt,nflowsd);
c7_1 = StateSpace([1],[2,3],A,B,C2,D,xo) #wie bei c6_1 c7_1 = StateSpace([1],[2,3],A,B,C2,D,xo) #wie bei c6_1
c7_2 = Gain([2,3],[4],-1*Fd) #wie bei c6_2 c7_2 = Gain([2,3],[4],-1*Fd) #wie bei c6_2
c7_4 = StateSpace([5],[6,7],A,B,C2,D,xo) #wie bei c6_4 c7_4 = StateSpace([5],[6,7],A,B,C2,D,xo) #wie bei c6_4
c7_5 = Gain([6,7],[8],-1*F) #wie bei c6_5 c7_5 = Gain([6,7],[8],-1*F) #wie bei c6_5
c7_7 = StateSpace([9],[10,11],A,B,C2,D,xo) #wie bei c6_7 c7_7 = StateSpace([9],[10,11],A,B,C2,D,xo) #wie bei c6_7
c7_8 = Gain([10,11],[9],-F) #wie bei c6_8 c7_8 = Gain([10,11],[9],-F) #wie bei c6_8
c7_3 = ZOH(4,1,Ts2); #wie bei c6_3 nur Ts wird hier zu Ts2 geändert c7_3 = ZOH(4,1,Ts2); #wie bei c6_3 nur Ts wird hier zu Ts2 geändert
c7_6 = ZOH(8,5,Ts2); #wie bei c6_6 nur Ts wird hier zu Ts2 geändert c7_6 = ZOH(8,5,Ts2); #wie bei c6_6 nur Ts wird hier zu Ts2 geändert
sc7.AddListComponents(np.array([c7_1,c7_2,c7_3,c7_4,c7_5,c7_6,c7_7,c7_8])) #Alles ohne Ts bleibt gleich sc7.AddListComponents(np.array([c7_1,c7_2,c7_3,c7_4,c7_5,c7_6,c7_7,c7_8])) #Alles ohne Ts bleibt gleich
out7 = sc7.Run(np.array([2,6])) out7 = sc7.Run(np.array([2,6]))
plt.plot(out7[0,:],out7[1,:],'r', out7[0,:],out7[2,:],'b'); plt.plot(out7[0,:],out7[1,:],'r', out7[0,:],out7[2,:],'b');
plt.legend(['discrete out','continuous out']) plt.legend(['discrete out','continuous out'])
plt.grid() plt.grid()
plt.show() plt.show()
``` ```
%% Output %% Output
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Das kontinuerliche System wird bei einer kleineren Abtastzeit $T_s=0.01$ hinreichend genau abgebildet. Das kontinuerliche System wird bei einer kleineren Abtastzeit $T_s=0.01$ hinreichend genau abgebildet.
%% Cell type:markdown id: tags:
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<img src="https://upload.wikimedia.org/wikipedia/commons/5/5d/Goddess_gif_small_12.gif" width="100"/>
<!--This image is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.-->
<!--Website with more information: https://commons.wikimedia.org/wiki/File:Goddess_gif_small_12.gif -->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment