Skip to content
Snippets Groups Projects
Commit dbaa9a88 authored by zhiyupan's avatar zhiyupan
Browse files

change the path of octsim

parent c69753d1
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:04105e65-6705-4c92-a009-48c54bd38ad4 tags: %% Cell type:markdown id:04105e65-6705-4c92-a009-48c54bd38ad4 tags:
# <span style='color:OrangeRed'>V1 DAS ABTASTTHEOREM </span> # <span style='color:OrangeRed'>V1 DAS ABTASTTHEOREM </span>
%% Cell type:markdown id:ffe7d73f-7986-44b6-a9fd-a678b9aaa182 tags: %% Cell type:markdown id:ffe7d73f-7986-44b6-a9fd-a678b9aaa182 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Hier wird analysiert, wie man die geeignete Abtastfrequenz für ein bestimmtes System auswählt. Am Ende überprüfen wir das Ergebnis mit einer einfachen Simulation. Hier wird analysiert, wie man die geeignete Abtastfrequenz für ein bestimmtes System auswählt. Am Ende überprüfen wir das Ergebnis mit einer einfachen Simulation.
Es ist das folgende System in Form einer Übertragungsfunktion gegeben Es ist das folgende System in Form einer Übertragungsfunktion gegeben
%% Cell type:code id:3a336fb9-2f73-44ce-ab67-91b96ccfc1c1 tags: %% Cell type:code id:3a336fb9-2f73-44ce-ab67-91b96ccfc1c1 tags:
``` octave ``` octave
% Necessary to use control toolbox % Necessary to use control toolbox
pkg load control pkg load control
clear all clear all
``` ```
%% Cell type:markdown id:53866cc1-a0ea-4d77-8d9c-c8345704d874 tags: %% Cell type:markdown id:53866cc1-a0ea-4d77-8d9c-c8345704d874 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Es ist das folgende System in Form einer Übertragungsfunktion gegeben Es ist das folgende System in Form einer Übertragungsfunktion gegeben
%% Cell type:code id:a0b9d775-f176-483e-aaca-43da284aa2e4 tags: %% Cell type:code id:a0b9d775-f176-483e-aaca-43da284aa2e4 tags:
``` octave ``` octave
num = [100] num = [100]
den = [1 10 100] den = [1 10 100]
G = tf(num,den) G = tf(num,den)
``` ```
%% Output %% Output
num = 100 num = 100
den = den =
1 10 100 1 10 100
Transfer function 'G' from input 'u1' to output ... Transfer function 'G' from input 'u1' to output ...
100 100
y1: ---------------- y1: ----------------
s^2 + 10 s + 100 s^2 + 10 s + 100
Continuous-time model. Continuous-time model.
%% Cell type:markdown id:1cb98bc6-138b-45bc-9178-74f8493d4171 tags: %% Cell type:markdown id:1cb98bc6-138b-45bc-9178-74f8493d4171 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Berechnet man die Nullstellen des Nenners, erhält man die Pole des Systems Berechnet man die Nullstellen des Nenners, erhält man die Pole des Systems
%% Cell type:code id:03459a21-1072-416b-a04b-5de7b9a30813 tags: %% Cell type:code id:03459a21-1072-416b-a04b-5de7b9a30813 tags:
``` octave ``` octave
p = roots(den) p = roots(den)
``` ```
%% Output %% Output
p = p =
-5.0000 + 8.6603i -5.0000 + 8.6603i
-5.0000 - 8.6603i -5.0000 - 8.6603i
%% Cell type:markdown id:071800da-0e16-4189-bb65-5746c0415165 tags: %% Cell type:markdown id:071800da-0e16-4189-bb65-5746c0415165 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Aus den Polen berechnen wir die Zeitkonstanten Aus den Polen berechnen wir die Zeitkonstanten
%% Cell type:code id:5adb101b-4286-428a-a4bd-eeb57e860e9c tags: %% Cell type:code id:5adb101b-4286-428a-a4bd-eeb57e860e9c tags:
``` octave ``` octave
tau = -1/real(p) tau = -1/real(p)
``` ```
%% Output %% Output
tau = tau =
0.100000 0.100000 0.100000 0.100000
%% Cell type:markdown id:eae75561-2795-400d-802d-f649281ff316 tags: %% Cell type:markdown id:eae75561-2795-400d-802d-f649281ff316 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
und aus den Zeitkonstanten die Eigenfrequenzen und aus den Zeitkonstanten die Eigenfrequenzen
%% Cell type:code id:acf57137-23eb-4be3-87ef-eb9d08076f07 tags: %% Cell type:code id:acf57137-23eb-4be3-87ef-eb9d08076f07 tags:
``` octave ``` octave
om = 2*pi./tau om = 2*pi./tau
``` ```
%% Output %% Output
om = om =
62.832 62.832 62.832 62.832
%% Cell type:markdown id:ab36a55a-6239-4214-9d36-85f4d111c61e tags: %% Cell type:markdown id:ab36a55a-6239-4214-9d36-85f4d111c61e tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
die minimale Abtastfrequenz ist durch das Zweifache der maximalen Eigenfrequenz des Systems gegeben die minimale Abtastfrequenz ist durch das Zweifache der maximalen Eigenfrequenz des Systems gegeben
%% Cell type:code id:c4c1fce4-7677-40d3-813e-5a5e4758f00f tags: %% Cell type:code id:c4c1fce4-7677-40d3-813e-5a5e4758f00f tags:
``` octave ``` octave
minomt = 2*max(om) minomt = 2*max(om)
``` ```
%% Output %% Output
minomt = 125.66 minomt = 125.66
%% Cell type:markdown id:c5fb33ea-47d7-49bf-a8ce-f1d81917a1d0 tags: %% Cell type:markdown id:c5fb33ea-47d7-49bf-a8ce-f1d81917a1d0 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Wir wählen dann einen Wert, der größer ist als das Minimum durch den Koeffizienten K Wir wählen dann einen Wert, der größer ist als das Minimum durch den Koeffizienten K
%% Cell type:code id:14c39a24-fc50-4924-8075-84125990776f tags: %% Cell type:code id:14c39a24-fc50-4924-8075-84125990776f tags:
``` octave ``` octave
K = 2 K = 2
omt = K*minomt omt = K*minomt
``` ```
%% Output %% Output
K = 2 K = 2
omt = 251.33 omt = 251.33
%% Cell type:markdown id:25ea2215-45ca-4980-a862-372d0eccf237 tags: %% Cell type:markdown id:25ea2215-45ca-4980-a862-372d0eccf237 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Schließlich testen wir die Wahl der Abtastzeit, indem wir die Sprungantwort simulieren und den Ausgang abtasten Schließlich testen wir die Wahl der Abtastzeit, indem wir die Sprungantwort simulieren und den Ausgang abtasten
%% Cell type:code id:578daff8-f4fd-4001-bb09-aea89d809eec tags: %% Cell type:code id:578daff8-f4fd-4001-bb09-aea89d809eec tags:
``` octave ``` octave
addpath("./Octsim"); addpath("../Octsim");
tini = 0 # Start time tini = 0 # Start time
tfinal = 3 # End time tfinal = 3 # End time
dt = 0.001 # Time Step dt = 0.001 # Time Step
nflows = 3 #Number of data flows in the schematic, Zahlenwert entspricht nicht dem in Matlab (hier um 1 größer) nflows = 3 #Number of data flows in the schematic, Zahlenwert entspricht nicht dem in Matlab (hier um 1 größer)
Ts = 2*pi/omt # Sampling time for discrete time Ts = 2*pi/omt # Sampling time for discrete time
c1{1} = StepSource(1,0,1,0.1); #StepSource(self,out,startv,endv,ts) c1{1} = StepSource(1,0,1,0.1); #StepSource(self,out,startv,endv,ts)
c1{2} = TransferFunction(1,2,num,den); #TransferFunction(self,inp,out,num,den) c1{2} = TransferFunction(1,2,num,den); #TransferFunction(self,inp,out,num,den)
c1{3} = DTTransferFunction(2,3,1,1,Ts); #DTTransferFunction(self,inp,out,num,den,Ts) c1{3} = DTTransferFunction(2,3,1,1,Ts); #DTTransferFunction(self,inp,out,num,den,Ts)
% Instance of the simulation schematic % Instance of the simulation schematic
sc1 = Schema(tini,tfinal,dt,nflows); sc1 = Schema(tini,tfinal,dt,nflows);
sc1.AddListComponents(c1); sc1.AddListComponents(c1);
% Run the schematic and plot % Run the schematic and plot
out1 = sc1.Run([1 2 3]); out1 = sc1.Run([1 2 3]);
plot(out1(1,:),out1(2,:),out1(1,:),out1(3,:),out1(1,:),out1(4,:)); plot(out1(1,:),out1(2,:),out1(1,:),out1(3,:),out1(1,:),out1(4,:));
``` ```
%% Output %% Output
tini = 0 tini = 0
tfinal = 3 tfinal = 3
dt = 0.0010000 dt = 0.0010000
nflows = 3 nflows = 3
Ts = 0.025000 Ts = 0.025000
%% Cell type:code id:9e1a668f-07ac-442a-bb62-950dacd49832 tags: %% Cell type:code id:9e1a668f-07ac-442a-bb62-950dacd49832 tags:
``` octave ``` octave
``` ```
%% Cell type:code id:65f46b62-e607-456a-80b6-42f452d0abfc tags: %% Cell type:code id:65f46b62-e607-456a-80b6-42f452d0abfc tags:
``` octave ``` octave
``` ```
......
%% Cell type:markdown id:04105e65-6705-4c92-a009-48c54bd38ad4 tags: %% Cell type:markdown id:04105e65-6705-4c92-a009-48c54bd38ad4 tags:
# <span style='color:OrangeRed'>V3 STABILTÄT DISKRETER SYSTEME </span> # <span style='color:OrangeRed'>V3 STABILTÄT DISKRETER SYSTEME </span>
%% Cell type:markdown id:ffe7d73f-7986-44b6-a9fd-a678b9aaa182 tags: %% Cell type:markdown id:ffe7d73f-7986-44b6-a9fd-a678b9aaa182 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Wir analysieren hier die Stabilität von diskreten Systemen mit zwei Methoden: Jury und w. Am Ende validieren wir die Ergebnisse mit einer Sprungantwort. Wir betrachten nur ein System zweiter Ordnung Wir analysieren hier die Stabilität von diskreten Systemen mit zwei Methoden: Jury und w. Am Ende validieren wir die Ergebnisse mit einer Sprungantwort. Wir betrachten nur ein System zweiter Ordnung
%% Cell type:code id:3a336fb9-2f73-44ce-ab67-91b96ccfc1c1 tags: %% Cell type:code id:3a336fb9-2f73-44ce-ab67-91b96ccfc1c1 tags:
``` octave ``` octave
% Necessary to use control toolbox % Necessary to use control toolbox
pkg load control pkg load control
clear all clear all
``` ```
%% Cell type:markdown id:53866cc1-a0ea-4d77-8d9c-c8345704d874 tags: %% Cell type:markdown id:53866cc1-a0ea-4d77-8d9c-c8345704d874 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Es ist das folgende System in Form einer Übertragungsfunktion gegeben Es ist das folgende System in Form einer Übertragungsfunktion gegeben
%% Cell type:code id:a0b9d775-f176-483e-aaca-43da284aa2e4 tags: %% Cell type:code id:a0b9d775-f176-483e-aaca-43da284aa2e4 tags:
``` octave ``` octave
a1 = 1 a1 = 1
a2 = 2 a2 = 2
b1 = 0.1 b1 = 0.1
b2 = 0.2 b2 = 0.2
num = [a1 a2] num = [a1 a2]
den = [1 b1 b2] den = [1 b1 b2]
G = tf(num,den, 1) G = tf(num,den, 1)
``` ```
%% Output %% Output
a1 = 1 a1 = 1
a2 = 2 a2 = 2
b1 = 0.10000 b1 = 0.10000
b2 = 0.20000 b2 = 0.20000
num = num =
1 2 1 2
den = den =
1.00000 0.10000 0.20000 1.00000 0.10000 0.20000
Transfer function 'G' from input 'u1' to output ... Transfer function 'G' from input 'u1' to output ...
z + 2 z + 2
y1: ----------------- y1: -----------------
z^2 + 0.1 z + 0.2 z^2 + 0.1 z + 0.2
Sampling time: 1 s Sampling time: 1 s
Discrete-time model. Discrete-time model.
%% Cell type:markdown id:1cb98bc6-138b-45bc-9178-74f8493d4171 tags: %% Cell type:markdown id:1cb98bc6-138b-45bc-9178-74f8493d4171 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Berechnet man die Nullstellen des Nenners, erhält man die Pole des Systems Berechnet man die Nullstellen des Nenners, erhält man die Pole des Systems
%% Cell type:code id:03459a21-1072-416b-a04b-5de7b9a30813 tags: %% Cell type:code id:03459a21-1072-416b-a04b-5de7b9a30813 tags:
``` octave ``` octave
p = roots(den) p = roots(den)
q = abs(p) q = abs(p)
``` ```
%% Output %% Output
p = p =
-0.05000 + 0.44441i -0.05000 + 0.44441i
-0.05000 - 0.44441i -0.05000 - 0.44441i
q = q =
0.44721 0.44721
0.44721 0.44721
%% Cell type:markdown id:071800da-0e16-4189-bb65-5746c0415165 tags: %% Cell type:markdown id:071800da-0e16-4189-bb65-5746c0415165 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Die Pole müssen sich im Inneren des Einheitskreises befinden. Das bedeutet, dass die Werte von q kleiner als 1 sein müssen Die Pole müssen sich im Inneren des Einheitskreises befinden. Das bedeutet, dass die Werte von q kleiner als 1 sein müssen
%% Cell type:markdown id:c9e8bd3b-e932-4710-9a6a-220f67d882e9 tags: %% Cell type:markdown id:c9e8bd3b-e932-4710-9a6a-220f67d882e9 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Dann wenden wir das Jury-Kriterium an. Zuerst bewerten wir die Funktion in 1 und -1 Dann wenden wir das Jury-Kriterium an. Zuerst bewerten wir die Funktion in 1 und -1
%% Cell type:code id:5adb101b-4286-428a-a4bd-eeb57e860e9c tags: %% Cell type:code id:5adb101b-4286-428a-a4bd-eeb57e860e9c tags:
``` octave ``` octave
F1 = 1+b1+b2 F1 = 1+b1+b2
Fm1 = 1-b1+b2 Fm1 = 1-b1+b2
``` ```
%% Output %% Output
F1 = 1.3000 F1 = 1.3000
Fm1 = 1.1000 Fm1 = 1.1000
%% Cell type:markdown id:eae75561-2795-400d-802d-f649281ff316 tags: %% Cell type:markdown id:eae75561-2795-400d-802d-f649281ff316 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
F1 und Fm1 müssen positive sein F1 und Fm1 müssen positive sein
%% Cell type:markdown id:fb81055e-1e14-4401-afb2-f90884c549be tags: %% Cell type:markdown id:fb81055e-1e14-4401-afb2-f90884c549be tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Die letzte Bedingung ist, dass der Betrag von a2 kleiner als 1 sein muss. Die letzte Bedingung ist, dass der Betrag von a2 kleiner als 1 sein muss.
%% Cell type:code id:acf57137-23eb-4be3-87ef-eb9d08076f07 tags: %% Cell type:code id:acf57137-23eb-4be3-87ef-eb9d08076f07 tags:
``` octave ``` octave
pkg load symbolic pkg load symbolic
syms z syms z
syms w syms w
F1 = (a1*z+a2)/(z^2 + b1*z +b2) F1 = (a1*z+a2)/(z^2 + b1*z +b2)
F2 = subs(F1,z,(1+w)/(1-w)) F2 = subs(F1,z,(1+w)/(1-w))
simplify(F2) simplify(F2)
``` ```
%% Output %% Output
Symbolic pkg v2.9.0: Python communication link active, SymPy v1.5.1. Symbolic pkg v2.9.0: Python communication link active, SymPy v1.5.1.
warning: passing floating-point values to sym is dangerous, see "help sym" warning: passing floating-point values to sym is dangerous, see "help sym"
warning: called from warning: called from
double_to_sym_heuristic at line 50 column 7 double_to_sym_heuristic at line 50 column 7
sym at line 379 column 13 sym at line 379 column 13
mtimes at line 63 column 5 mtimes at line 63 column 5
warning: passing floating-point values to sym is dangerous, see "help sym" warning: passing floating-point values to sym is dangerous, see "help sym"
warning: called from warning: called from
double_to_sym_heuristic at line 50 column 7 double_to_sym_heuristic at line 50 column 7
sym at line 379 column 13 sym at line 379 column 13
plus at line 61 column 5 plus at line 61 column 5
F1 = (sym) F1 = (sym)
z + 2 z + 2
─────────── ───────────
2 z 1 2 z 1
z + ── + ─ z + ── + ─
10 5 10 5
F2 = (sym) F2 = (sym)
w + 1 w + 1
2 + ───── 2 + ─────
1 - w 1 - w
───────────────────────── ─────────────────────────
2 2
1 w + 1 (w + 1) 1 w + 1 (w + 1)
─ + ────────── + ──────── ─ + ────────── + ────────
5 10⋅(1 - w) 2 5 10⋅(1 - w) 2
(1 - w) (1 - w)
ans = (sym) ans = (sym)
⎛ 2 ⎞ ⎛ 2 ⎞
10⋅⎝w - 4⋅w + 3⎠ 10⋅⎝w - 4⋅w + 3⎠
───────────────── ─────────────────
2 2
11⋅w + 16⋅w + 13 11⋅w + 16⋅w + 13
%% Cell type:markdown id:56641183-2cb4-48c2-b61d-7f612a56d0a7 tags: %% Cell type:markdown id:56641183-2cb4-48c2-b61d-7f612a56d0a7 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Alle Zeichen im Nenner müssen positiv sein. Alle Zeichen im Nenner müssen positiv sein.
%% Cell type:markdown id:ab36a55a-6239-4214-9d36-85f4d111c61e tags: %% Cell type:markdown id:ab36a55a-6239-4214-9d36-85f4d111c61e tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify"> <div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Zum Schluss überprüfen wir die Ergebnisse mit der Simulation einer Sprungantwort Zum Schluss überprüfen wir die Ergebnisse mit der Simulation einer Sprungantwort
%% Cell type:code id:578daff8-f4fd-4001-bb09-aea89d809eec tags: %% Cell type:code id:578daff8-f4fd-4001-bb09-aea89d809eec tags:
``` octave ``` octave
addpath("./Octsim"); addpath("../Octsim");
tini = 0 # Start time tini = 0 # Start time
tfinal = 20 # End time tfinal = 20 # End time
dt = 0.1 # Time Step dt = 0.1 # Time Step
nflows = 2 #Number of data flows in the schematic, Zahlenwert entspricht nicht dem in Matlab (hier um 1 größer) nflows = 2 #Number of data flows in the schematic, Zahlenwert entspricht nicht dem in Matlab (hier um 1 größer)
Ts = 1 # Sampling time for discrete time Ts = 1 # Sampling time for discrete time
c1{1} = StepSource(1,0,1,0.1); #StepSource(self,out,startv,endv,ts) c1{1} = StepSource(1,0,1,0.1); #StepSource(self,out,startv,endv,ts)
c1{2} = DTTransferFunction(1,2,num,den,Ts); #DTTransferFunction(self,inp,out,num,den,Ts) c1{2} = DTTransferFunction(1,2,num,den,Ts); #DTTransferFunction(self,inp,out,num,den,Ts)
% Instance of the simulation schematic % Instance of the simulation schematic
sc1 = Schema(tini,tfinal,dt,nflows); sc1 = Schema(tini,tfinal,dt,nflows);
sc1.AddListComponents(c1); sc1.AddListComponents(c1);
% Run the schematic and plot % Run the schematic and plot
out1 = sc1.Run([1 2]); out1 = sc1.Run([1 2]);
plot(out1(1,:),out1(2,:),out1(1,:),out1(3,:)); plot(out1(1,:),out1(2,:),out1(1,:),out1(3,:));
``` ```
%% Output %% Output
tini = 0 tini = 0
tfinal = 20 tfinal = 20
dt = 0.10000 dt = 0.10000
nflows = 2 nflows = 2
Ts = 1 Ts = 1
%% Cell type:code id:9e1a668f-07ac-442a-bb62-950dacd49832 tags: %% Cell type:code id:9e1a668f-07ac-442a-bb62-950dacd49832 tags:
``` octave ``` octave
``` ```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment