Skip to content
Snippets Groups Projects
Commit 7c3d7eeb authored by Sebastian Schwarz's avatar Sebastian Schwarz
Browse files

add V05.2.ipynb

parent ee3d1d1c
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:6cfcdd9e-6413-43fd-bb20-950c852ec0f7 tags:
# <span style='color:OrangeRed'>V5 ZUSTANDRAUMDARSTELLUNG TEIL 2</span>
%% Cell type:markdown id:9653081e-df65-4ccd-9204-e11c542a469f tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
In dieser Aufgabe soll das Zustandsraummodell eines Wasserstoff-Elektrolyse-Stacks bestimmt werden. Für den Wasserstoff-Elektrolyse-Stack ist das folgende Ersatzschaltbild gegeben. Der Eingang ist u(t) = v(t) - v_rev(t). Die gemessene Ausgangsgröße ist y(t) = i_L(t).
%% Cell type:markdown id:aaadb57b-f7ac-4db7-baf6-b300fb0d826f tags:
<img src="figures/circuitel.png" alt="drawing" width="600" height="300"/>
%% Cell type:markdown id:a27e62db-897e-41e8-9b56-fd8c6b48f3bf tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Das Zustandsraummodel hat zwei Zustände: die Spannung des Kondensators und der Strom der Spule.
%% Cell type:code id:ef3d3be5-73cd-48d2-a773-d177b638230a tags:
``` octave
clear all
pkg load symbolic
warning('off', 'all');
syms C
syms R1
syms R2
syms L
A = [-R2/L -1/L; 1/C -1/(C*R1)]
B = [1/L; 0]
```
%% Output
Symbolic pkg v2.8.0: Python communication link active, SymPy v1.5.1.
A = (sym 2×2 matrix)
⎡-R₂ -1 ⎤
⎢──── ─── ⎥
⎢ L L ⎥
⎢ ⎥
⎢ 1 -1 ⎥
⎢ ─ ────⎥
⎣ C C⋅R₁⎦
B = (sym 2×1 matrix)
⎡1⎤
⎢─⎥
⎢L⎥
⎢ ⎥
⎣0⎦
%% Cell type:markdown id:1943a7dc-b837-4623-8792-a1775026155d tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Die folgenden Parameter seien gegeben:
%% Cell type:code id:402f525f-8a64-4584-8d05-dbd5e42e5516 tags:
``` octave
Lv = 0.5
Cv = 0.1
R1v = 1.0
R2v = 0.5
```
%% Output
Lv = 0.50000
Cv = 0.10000
R1v = 1
R2v = 0.50000
%% Cell type:markdown id:971a3f7a-3c0d-4a88-895f-3777326d7440 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Mit dieser Parametrisierung können die Matrizen für den Zustandsraum wie folgt berechnet werden:
%% Cell type:code id:d8ab8054-efd1-4987-9600-24dbe480a40e tags:
``` octave
As = subs(A,{L,C,R1,R2},{Lv,Cv,R1v,R2v})
Av = double(As)
Bs = subs(B,{L,C,R1,R2},{Lv,Cv,R1v,R2v})
Bv = double(Bs)
```
%% Output
As = (sym 2×2 matrix)
⎡-1 -2 ⎤
⎢ ⎥
⎣10 -10⎦
Av =
-1 -2
10 -10
Bs = (sym 2×1 matrix)
⎡2⎤
⎢ ⎥
⎣0⎦
Bv =
2
0
%% Cell type:markdown id:9d90b015-72bf-4fb8-82a0-4ec0701232f6 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Diskretisieren Sie das Zustandsraummodel (unter Berücksichtigung eines Haltegliedes 0. Ordnung). Verwenden Sie hierbei zur Berechnung der Fundamentalmatrix das Cayley-Hamilton Theorem. Die Abtastzeit beträgt Ts = 0,1sec.
%% Cell type:markdown id:8629e5a2-ae35-418d-8a65-7e511440917e tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Im ersten Schritt müssen wir die Eigenwerte der Systemmatrix berechnen:
%% Cell type:code id:1ed03ed5-3913-4107-95c9-f48e52bb50ee tags:
``` octave
p = eigs(Av)
```
%% Output
p =
-6.0000
-5.0000
%% Cell type:markdown id:0353e887-ebe2-44d0-b7fb-a191622cabff tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Dann wenden wir das Caley-Hamilton-Theorem an:
%% Cell type:code id:0d90c253-316f-47ed-9f7b-561ff0ed4868 tags:
``` octave
Ts = 0.1;
Ac = [1 p(1);1 p(2)]
Bc = [expm(p(1)*Ts);expm(p(2)*Ts)]
alfa = inv(Ac)*Bc
```
%% Output
Ac =
1.0000 -6.0000
1.0000 -5.0000
Bc =
0.54881
0.60653
alfa =
0.895126
0.057719
%% Cell type:markdown id:d4fac333-e43d-49c7-aaec-6168b86bd6a6 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Und dann:
%% Cell type:code id:828217c8-bd90-42da-8b36-9e1f05727a24 tags:
``` octave
Fi = alfa(1)*eye(2)+alfa(2)*Av
```
%% Output
Fi =
0.83741 -0.11544
0.57719 0.31794
%% Cell type:markdown id:a6ed8d3e-8d76-451c-8480-7182a8723ab2 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Wir vergleichen Berechnungen mit Octave/Octsim:
%% Cell type:code id:058ad783-d553-4bcc-873c-a6f521c16975 tags:
``` octave
Fio = expm(Av*Ts)
```
%% Output
Fio =
0.83741 -0.11544
0.57719 0.31794
%% Cell type:markdown id:63fb7dec-c4e2-4e53-b6f9-bea0649fd521 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Die Fundamentalmatrix können wir wie folgt berechnen:
%% Cell type:code id:0c2d94f8-536c-421a-98ae-69771c0e6ca2 tags:
``` octave
syms t
expr = expm(Av*t)
Gi = eval(int(expr,t,0,Ts)*Bv)
```
%% Output
expr = (sym 2×2 matrix)
⎡ -5⋅t -6⋅t -5⋅t -6⋅t⎤
⎢ 5⋅ℯ - 4⋅ℯ - 2⋅ℯ + 2⋅ℯ ⎥
⎢ ⎥
⎢ -5⋅t -6⋅t -5⋅t -6⋅t⎥
⎣10⋅ℯ - 10⋅ℯ - 4⋅ℯ + 5⋅ℯ ⎦
Gi =
0.185354
0.069916
%% Cell type:markdown id:8a4be558-f51c-415e-96f7-922b8e417422 tags:
<div style="font-family: 'times'; font-size: 13pt; text-align: justify">
Zum Vergleich:
%% Cell type:code id:69e7fd06-f71a-48ec-af34-d2e406f9067c tags:
``` octave
pkg load control
C = [1 0]
D = 0
sys = ss(Av,Bv,C,D)
c2d(sys,Ts,'zoh')
```
%% Output
C =
1 0
D = 0
sys.a =
x1 x2
x1 -1 -2
x2 10 -10
sys.b =
u1
x1 2
x2 0
sys.c =
x1 x2
y1 1 0
sys.d =
u1
y1 0
Continuous-time model.
ans.a =
x1 x2
x1 0.8374 -0.1154
x2 0.5772 0.3179
ans.b =
u1
x1 0.1854
x2 0.06992
ans.c =
x1 x2
y1 1 0
ans.d =
u1
y1 0
Sampling time: 0.1 s
Discrete-time model.
%% Cell type:markdown id:3e5f08c8-020f-4ec1-af60-64281e28388e tags:
Eine weitere Möglichkeit ist die Verwendung der inversen Laplace-Transformation:
%% Cell type:code id:71ef35e6-15e0-441d-9d8e-58fccbd7bc8d tags:
``` octave
syms s
syms t
IA = 1/(s*s-(p(1)+p(2))*s+p(1)*p(2))*[s-Av(2,2) Av(1,2); Av(2,1) s-Av(1,1)]
```
%% Output
IA = (sym 2×2 matrix)
⎡ s + 10 -2 ⎤
⎢────────────── ──────────────⎥
⎢ 2 2 ⎥
⎢s + 11⋅s + 30 s + 11⋅s + 30⎥
⎢ ⎥
⎢ 10 s + 1 ⎥
⎢────────────── ──────────────⎥
⎢ 2 2 ⎥
⎣s + 11⋅s + 30 s + 11⋅s + 30⎦
%% Cell type:code id:b591b379-c130-4ecb-9f0b-8fb4a0558186 tags:
``` octave
F11 = ilaplace(IA(1,1),t)
```
%% Output
F11 = (sym)
⎛ t ⎞ -6⋅t
⎝5⋅ℯ - 4⎠⋅ℯ ⋅θ(t)
%% Cell type:code id:85a9e63e-606e-459a-998d-d3fb9fdc9ae8 tags:
``` octave
F12 = ilaplace(IA(1,2),t)
```
%% Output
F12 = (sym)
⎛ t⎞ -6⋅t
2⋅⎝1 - ℯ ⎠⋅ℯ ⋅θ(t)
%% Cell type:code id:c052644a-ed96-4d90-8334-a550a8456dac tags:
``` octave
F21 = ilaplace(IA(2,1),t)
```
%% Output
F21 = (sym)
⎛ t ⎞ -6⋅t
10⋅⎝ℯ - 1⎠⋅ℯ ⋅θ(t)
%% Cell type:code id:37bc5ef8-e669-413a-a35c-46f5c95062c7 tags:
``` octave
F22 = ilaplace(IA(2,2),t)
```
%% Output
F22 = (sym)
⎛ t ⎞ -6⋅t
-⎝4⋅ℯ - 5⎠⋅ℯ ⋅θ(t)
%% Cell type:code id:cf9514ee-097c-4548-8124-982255128efb tags:
``` octave
Fil = [double(subs(F11,t,Ts)) double(subs(F12,t,Ts)); double(subs(F21,t,Ts)) double(subs(F22,t,Ts))]
```
%% Output
Fil =
0.83741 -0.11544
0.57719 0.31794
%% Cell type:code id:f2df9672-8ad4-4052-9dd2-bb9d18937e83 tags:
``` octave
```
sys2-jupyter-notebooks/exam_examples/figures/circuitel.png

126 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment