GDET3 RL-Hochpass.ipynb 14.3 KB
Newer Older
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
1
2
3
4
5
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
6
7
8
9
10
   "metadata": {
    "jupyter": {
     "source_hidden": true
    }
   },
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
11
12
   "outputs": [],
   "source": [
13
    "# Copyright 2020 Institut für Nachrichtentechnik, RWTH Aachen University\n",
14
    "%matplotlib widget\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
15
16
17
18
19
20
21
    "\n",
    "from ipywidgets import interact, interactive\n",
    "import ipywidgets as widgets\n",
    "from IPython.display import clear_output, display, HTML\n",
    "\n",
    "from scipy import signal\n",
    "\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
22
    "from ient_nb.ient_plots import *\n",
23
    "from ient_nb.ient_signals import *"
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
24
25
26
   ]
  },
  {
Christian Rohlfing's avatar
Christian Rohlfing committed
27
28
   "cell_type": "markdown",
   "metadata": {},
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
29
   "source": [
Christian Rohlfing's avatar
Christian Rohlfing committed
30
31
32
33
34
    "<div class=\"inline-block\">\n",
    "    <img src=\"ient_nb/figures/rwth_ient_logo@2x.png\" style=\"float: right;height: 5em;\">\n",
    "</div>\n",
    "\n",
    "# RL-Netzwerk"
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
35
36
37
38
39
40
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
41
    "Dieses Notebook dient der Veranschaulichung von Übungsaufgabe 3.1. \n",
Iris Heisterklaus's avatar
Iris Heisterklaus committed
42
43
44
    "\n",
    "Es wird folgendes RL-Netzwerk betrachtet:\n",
    "\n",
45
    "![Blockdiagramm](figures/rl_highpass_block_diagram.png)\n",
Iris Heisterklaus's avatar
Iris Heisterklaus committed
46
    "\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
47
48
    "## Berechnung von Betrag und Phase\n",
    "\n",
Iris Heisterklaus's avatar
Iris Heisterklaus committed
49
    "Es gilt für die Spannung \n",
Christian Rohlfing's avatar
Christian Rohlfing committed
50
    "$U_1(F) = R I_1(F)+U_2(F)$ \n",
Iris Heisterklaus's avatar
Iris Heisterklaus committed
51
52
    "und den Strom\n",
    "$\\displaystyle I_1(F) = \\frac{U_2(F)}{\\mathrm{j}2 \\pi F L}$.\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
53
    "\n",
Iris Heisterklaus's avatar
Iris Heisterklaus committed
54
    "Dies ergibt\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
55
    "$U_1(F) = U_2(F) \\left[ \\frac{R}{\\mathrm{j} 2\\pi F L} + 1\\right]$ \n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
56
    "bzw.\n",
Iris Heisterklaus's avatar
Iris Heisterklaus committed
57
    "$\\displaystyle H(F) = \\frac{U_2(F)}{U_1(F)} =  \\frac{\\mathrm{j}2 \\pi F L}{R+\\mathrm{j} 2 \\pi F L}$.\n",
58
    "\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
59
60
61
62
63
64
65
66
67
68
    "Mit \n",
    "$T = \\frac{L}{R}$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Christian Rohlfing's avatar
Christian Rohlfing committed
69
    "T = 1e-6"
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
70
71
72
73
74
75
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
Christian Rohlfing's avatar
Christian Rohlfing committed
76
    "folgt $\\displaystyle H(F) =  \\frac{\\mathrm{j} 2 \\pi FT}{1+\\mathrm{j}2 \\pi F T}$.\n",
77
    "\n",
Iris Heisterklaus's avatar
Iris Heisterklaus committed
78
    "Eliminiere komplexen Term im Nenner:\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
79
    "$\\displaystyle H(F)\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
80
    "= \\frac{\\mathrm{j} 2 \\pi F T}{1+\\mathrm{j}2 \\pi FT} \\frac{1-\\mathrm{j}2 \\pi FT}{1-\\mathrm{j}2 \\pi FT} \n",
81
82
    "= \\frac{\\mathrm{j}2\\pi F T+\\left(2\\pi F T\\right)^2}{1+\\left(2 \\pi F T\\right)^2}$\n",
    "\n",
Iris Heisterklaus's avatar
Iris Heisterklaus committed
83
    "Somit folgt für den Betrag \n",
Christian Rohlfing's avatar
Christian Rohlfing committed
84
85
    "$$|H(F)|\n",
    "= \\frac{|2\\pi F T|}{\\sqrt{1+\\left(2 \\pi F T\\right)^2}}$$"
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
86
87
88
89
90
91
92
93
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Christian Rohlfing's avatar
Christian Rohlfing committed
94
    "def Habs(F):\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
95
    "    return abs(2*np.pi*F*T)/np.sqrt(1+(2*np.pi*F*T)**2);"
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
96
97
98
99
100
101
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
Iris Heisterklaus's avatar
Iris Heisterklaus committed
102
    "und die Phase \n",
Christian Rohlfing's avatar
Christian Rohlfing committed
103
104
    "$$\\varphi(F)\n",
    "= \\mathrm{arctan}\\left(\\frac{\\mathrm{Im}\\left\\{H(F)\\right\\}}{\\mathrm{Re}\\left\\{H(F)\\right\\}}\\right) \n",
Iris Heisterklaus's avatar
Iris Heisterklaus committed
105
    "= \\mathrm{arctan}\\left(\\frac{1}{2\\pi F T}\\right)\\text{.}$$"
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
106
107
108
109
110
111
112
113
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Christian Rohlfing's avatar
Christian Rohlfing committed
114
115
    "def Hphi(F): \n",
    "    return np.arctan(1/(2*np.pi*F*T));"
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
116
117
   ]
  },
Christian Rohlfing's avatar
Christian Rohlfing committed
118
119
120
121
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
Iris Heisterklaus's avatar
Iris Heisterklaus committed
122
    "Plotte $|H(F)|$ und $\\varphi(F)$:"
Christian Rohlfing's avatar
Christian Rohlfing committed
123
124
125
126
127
128
129
130
131
132
133
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "RL = 1/T; RLF = RL/(2*np.pi);\n",
    "(F, deltaF) = np.linspace(-.75, .75, 4001, retstep=True) + eps # F-axis in MHz\n",
    "\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
134
    "# Plot\n",
135
    "fig, axs = plt.subplots(1, 2, figsize=(8,4));\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
136
137
138
139
140
141
    "ax = axs[0]; ax.plot(F, Habs(F*1e6), 'rwth');\n",
    "ax.plot([-RLF/1e6, RLF/1e6], [1/np.sqrt(2), 1/np.sqrt(2)], 'k--', \n",
    "        [-RLF/1e6,-RLF/1e6], [0, 1/np.sqrt(2)], 'k--', \n",
    "        [RLF/1e6,RLF/1e6], [0, 1/np.sqrt(2)], 'k--');\n",
    "ax.set_yticks([0,1/np.sqrt(2), 1]); ax.set_yticklabels([r'$0$', r'$1/\\sqrt{2}$', r'$1$']); \n",
    "ax.set_xlabel(r'$\\rightarrow F$  [MHz]'); ax.set_ylabel(r'$\\uparrow |H(F)|$'); ient_axis(ax);\n",
142
    "ax.yaxis.get_major_ticks()[1].label.set_verticalalignment('bottom');\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
143
144
145
146
147
148
149
150
151
152
153
    "\n",
    "ax = axs[1]; ax.plot(F, Hphi(F*1e6), 'rwth');\n",
    "ax.plot([-RLF/1e6, 0], [-np.pi/4, -np.pi/4], 'k--', \n",
    "        [-RLF/1e6,-RLF/1e6], [0, -np.pi/4], 'k--', \n",
    "        [RLF/1e6, 0], [np.pi/4, np.pi/4], 'k--', \n",
    "        [RLF/1e6,RLF/1e6], [0, np.pi/4], 'k--');\n",
    "ax.set_yticks([-np.pi/2,-np.pi/4,0,np.pi/4,np.pi/2]); \n",
    "ax.set_yticklabels([r'$-\\pi/2$', r'$-\\pi/4$', r'$0$', r'$\\pi/4$',r'$\\pi/2$']); \n",
    "ax.set_xlabel(r'$\\rightarrow F$ [MHz]'); ax.set_ylabel(r'$\\uparrow \\varphi(F)$'); ient_axis(ax);"
   ]
  },
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Werte Betrag und Phase aus für $F=100\\ \\mathrm{kHz}$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "F = 100e3; # Hz\n",
    "print('|H(F)| = {0:.3f}'.format(Habs(F)))\n",
    "print('phi(F) = {0:.3f}°'.format(Hphi(F)*180/np.pi))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Werte Betrag und Phase aus für $F=300\\ \\mathrm{kHz}$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print('|H(3F)| = {0:.3f}'.format(Habs(3*F)))\n",
    "print('phi(3F) = {0:.3f}°'.format(Hphi(3*F)*180/np.pi))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Zusätzlich Betrag für $F=0$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print('|H(0)| = {0:.3f}'.format(Habs(0)))"
   ]
  },
205
206
207
208
209
210
211
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Am Plot der Übertragungsfunktion und den berechneten Werten kann eindeutig erkannt werden, dass es sich hierbei um einen Hochpass handelt. Niedrige Frequenzen werden gedämpft, während hohe Frequenzen durchgelassen werden. "
   ]
  },
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
212
213
214
215
216
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Berechnung der Ausgangsspannung\n",
Iris Heisterklaus's avatar
Iris Heisterklaus committed
217
    "Die Eingangsspannung beträgt laut Aufgabenstellung \n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
218
    "\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
219
    "$u_1(t)\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
220
221
    "= 1 \\mathrm{V}\n",
    "+ 1 \\mathrm{V} \\cos\\left(2 \\pi F t\\right)\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
222
    "- 0{,}3 \\mathrm{V} \\cos\\left(6 \\pi F t\\right)$\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
223
    "\n",
Iris Heisterklaus's avatar
Iris Heisterklaus committed
224
225
    "Für die Ausgangsspannung gilt nun\n",
    "\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
226
    "$u_2(t)\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
227
    "= \\underbrace{ \n",
Christian Rohlfing's avatar
Christian Rohlfing committed
228
229
230
    "|H(0)|\\,1 \\mathrm{V}}_{=0}\n",
    "+  |H\\left(F\\right)|\\,1 \\mathrm{V}\\, \\cos\\left(2 \\pi F t + \\varphi(F)\\right)\n",
    "- 0{,}3  \\mathrm{V}\\, |H(3F)| \\cos\\left(2\\cdot3 \\pi F t + \\varphi(3F)\\right)\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
231
232
    "\\\\\n",
    "=  \n",
Christian Rohlfing's avatar
Christian Rohlfing committed
233
234
    "|H(F)| \\, 1 \\mathrm{V}\\, \\cos\\left(2 \\pi F \\left[t - t_0\\right]\\right)\n",
    "- 0{,}3\\mathrm{V}\\, |H(3F)| \\cos\\left(2\\cdot3 \\pi F \\left[t - t_1\\right]\\right)$\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
235
236
    "\n",
    "mit Phasenlaufzeiten\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
237
    "$\\displaystyle t_0 = -\\frac{\\varphi(F)}{2\\pi F}$ und $\\displaystyle t_1 = -\\frac{\\varphi(3F)}{6\\pi F}$"
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
238
239
240
241
242
243
244
245
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
246
    "phaseDelay = lambda F: -Hphi(F)/(2*np.pi*F);\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
247
248
249
250
251
252
253
254
255
256
257
258
    "print('t0 = {0:.3e} s'.format(phaseDelay(F)))\n",
    "print('t1 = {0:.3e} s'.format(phaseDelay(3*F)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Skizze der Eingangs- und Ausgangsspannungen\n",
    "\n",
    "### Skizze von beiden Komponenten von $u_2\\left(t\\right)$\n",
    "\n",
259
    "Skizze $|H\\left(F\\right)| \\cos\\left(2 \\pi F \\left[t-t_0\\right]\\right)$"
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
260
261
262
263
264
265
266
267
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Christian Rohlfing's avatar
Christian Rohlfing committed
268
269
    "def u2p1(t,F): # first component of u2(t)\n",
    "    return Habs(F)*np.cos(2*np.pi*F*(t-phaseDelay(F)));\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
270
    "\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
271
272
    "(t,deltat) = np.linspace(-10, 10, 10001, retstep=True) # t-axis\n",
    "t0 = phaseDelay(F) # Phase Delay\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
273
    "\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
274
    "# Plot\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
275
    "fig,ax = plt.subplots(1,1,figsize=(6,2)); ax.plot(t, u2p1(t/1e6,F), 'rwth'); \n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
276
    "ax.set_xlabel(r'$t/\\mu\\mathrm{s}\\rightarrow$',x=0.9); \n",
277
    "ax.set_ylabel(r'$\\uparrow |H\\left(F\\right)| \\cos\\left(2 \\pi F \\left[t-t_0\\right]\\right)$');\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
278
279
    "ax.plot([t0*1e6, t0*1e6], [0, u2p1(t0,F)], '--', color='grun', lw=1)\n",
    "ax.text(t0*1e6,0, r'$t_0$', fontsize=14, horizontalalignment='left', verticalalignment='top',color='grun')\n",
280
    "ax.set_xlim(-11, 11); ient_axis(ax);"
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
281
282
283
284
285
286
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
287
    "Skizze $|H\\left(3F\\right)| \\cos\\left(6 \\pi F \\left[t-t_1\\right]\\right)$"
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
288
289
290
291
292
293
294
295
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Christian Rohlfing's avatar
Christian Rohlfing committed
296
297
    "def u2p2(t,F): # second component of u2(t)\n",
    "    return Habs(3*F)*np.cos(6*np.pi*F*(t-phaseDelay(3*F)));\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
298
    "\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
299
    "t1 = phaseDelay(3*F) # phase delay\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
300
    "\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
301
    "# Plot\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
302
    "fig,ax = plt.subplots(1,1,figsize=(6,2)); ax.plot(t, u2p2(t/1e6,F), 'rwth');\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
303
    "ax.set_xlabel(r'$t/\\mu\\mathrm{s}\\rightarrow$'); \n",
304
    "ax.set_ylabel(r'$\\uparrow |H\\left(3F\\right)| \\cos\\left(6 \\pi F \\left[t-t_1\\right]\\right)$');\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
305
306
    "ax.plot([t1*1e6, t1*1e6], [0, u2p2(t1,F)], '--', color='grun', lw=1)\n",
    "ax.text(t1*1e6,0, r'$t_1$', fontsize=14, horizontalalignment='right', verticalalignment='top',color='grun')\n",
307
    "ax.set_xlim(-11, 11); ax.set_ylim(-1.5, 1.5); ient_axis(ax);"
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
308
309
310
311
312
313
314
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Skizze von\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
315
    "$$u_1(t) = 1 \\mathrm{V}\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
316
    "+ 1 \\mathrm{V} \\cos\\left(2 \\pi F t\\right)\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
317
    "- 0{,}3 \\mathrm{V} \\cos\\left(6 \\pi F t\\right)\\quad \\text{und}$$\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
318
    "\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
319
320
    "$$\n",
    "u_2(t)\n",
321
    "=  |H\\left(F\\right)|1 \\mathrm{V} \\cos\\left(2 \\pi F \\left[t-t_0\\right]\\right)\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
322
323
    "- 0{,}3\\mathrm{V}   |H\\left(3F\\right)| \\cos\\left(2\\cdot3 \\pi F \\left[t-t_1\\right]\\right)\n",
    "$$\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
324
325
326
327
328
329
330
331
332
    "für $F=100\\,\\mathrm{kHz}$ und $F=1\\,\\mathrm{MHz}$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
Christian Rohlfing's avatar
Christian Rohlfing committed
333
    "def u1(t, F): \n",
Christian Rohlfing's avatar
Christian Rohlfing committed
334
    "    return 1 + np.cos(2*np.pi*F*t) - 0.3*np.cos(6*np.pi*F*t);\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
335
    "def u2(t, F): \n",
Christian Rohlfing's avatar
Christian Rohlfing committed
336
    "    return u2p1(t,F) - 0.3*u2p2(t,F);\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
337
    "\n",
338
339
    "# Plot\n",
    "fig, axs = plt.subplots(1,2,figsize=(6,4));\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
340
    "ax = axs[0];\n",
341
342
343
344
    "ax.plot(t, u1(t/1e6,F), 'rwth', label=r'$u_1\\left(t\\right)/\\mathrm{V}$');\n",
    "ax.plot(t, u2(t/1e6,F), 'grun', label=r'$u_2\\left(t\\right)/\\mathrm{V}$');\n",
    "ax.set_title(r'$F=100\\,\\mathrm{kHz}$'); ax.set_xlabel(r'$t/\\mu\\mathrm{s}\\rightarrow$'); \n",
    "ax.set_xlim(-11, 11); ax.legend(); ient_axis(ax);\n",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
345
346
    "\n",
    "scale = 10;\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
347
    "ax = axs[1];\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
348
349
    "ax.plot(t, u1(t/1e6,F*scale), 'rwth', label=r'$u_1\\left(t\\right)/\\mathrm{V}$')\n",
    "ax.plot(t, u2(t/1e6,F*scale), 'grun', label=r'$u_2\\left(t\\right)/\\mathrm{V}$')\n",
350
351
    "ax.set_title(r'$F=1\\,\\mathrm{MHz}$'); ax.set_xlabel(r'$t/\\mu\\mathrm{s}\\rightarrow$'); \n",
    "ax.set_xlim(-11/scale, 11/scale); ax.legend(); ient_axis(ax);"
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
352
353
   ]
  },
354
  {
Christian Rohlfing's avatar
Christian Rohlfing committed
355
   "cell_type": "markdown",
356
357
   "metadata": {},
   "source": [
Christian Rohlfing's avatar
Christian Rohlfing committed
358
    "## Interaktive Demo"
359
360
   ]
  },
Christian Rohlfing's avatar
Christian Rohlfing committed
361
362
363
  {
   "cell_type": "code",
   "execution_count": null,
364
365
366
367
368
   "metadata": {
    "jupyter": {
     "source_hidden": true
    }
   },
Christian Rohlfing's avatar
Christian Rohlfing committed
369
   "outputs": [],
Christian Rohlfing's avatar
Christian Rohlfing committed
370
371
372
373
   "source": [
    "(f,deltaf) = np.linspace(-2, 2, 10001, retstep=True) # f-axis\n",
    "fig,axs = plt.subplots(1,2,figsize=(8,4));\n",
    "\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
374
375
376
377
378
    "@widgets.interact(Fsel=widgets.FloatSlider(min=.1, max=2, step=.1, value=.1, description='$F$ [MHz]'))\n",
    "def update_plot(Fsel):\n",
    "    u1scaled = u1(t/1e6, Fsel*1e6);\n",
    "    u2scaled = u2(t/1e6, Fsel*1e6)\n",
    "    if not axs[0].lines: # Call plot() and decorate axes. Usually, these functions take some processing time\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
379
    "        ax = axs[0];\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
380
381
    "        p1, = ax.plot(t, u1scaled, 'rwth', label=r'$u_1\\left(t\\right)/\\mathrm{V}$');\n",
    "        p2, = ax.plot(t, u2scaled, 'grun', label=r'$u_2\\left(t\\right)/\\mathrm{V}$');\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
382
383
384
    "        ax.set_xlim(-1.1/Fsel, 1.1/Fsel); \n",
    "        ax.set_xlabel(r'$t/\\mu\\mathrm{s}\\rightarrow$'); \n",
    "        ax.set_title(r'$F={}\\mathrm{{MHz}}$'.format(Fsel)); ient_axis(ax); ax.legend(); \n",
Christian Rohlfing's avatar
Christian Rohlfing committed
385
386
    "\n",
    "        ax = axs[1]; ax.plot(f,Habs(f*1e6))\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
387
    "        ax.plot([Fsel, Fsel], [0, Habs(Fsel*1e6)], 'ko--', lw=1);\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
388
    "        ax.set_xlabel(r'$\\rightarrow F/\\mathrm{MHz}$'); ax.set_ylabel(r'$\\uparrow |H(F)|$'); \n",
Christian Rohlfing's avatar
Christian Rohlfing committed
389
390
391
392
393
394
395
396
    "        ax.set_title(r'Übertragungsfunktion'); ient_axis(ax); \n",
    "        \n",
    "    else: # If lines exist, replace only xdata and ydata since plt.plot() takes longer time\n",
    "        axs[0].lines[0].set_ydata(u1scaled)\n",
    "        axs[0].lines[1].set_ydata(u2scaled)\n",
    "        axs[1].lines[1].set_xdata([Fsel, Fsel])\n",
    "        axs[1].lines[1].set_ydata([0, Habs(Fsel*1e6)])\n",
    "        axs[0].set_xlim(-1.1/Fsel, 1.1/Fsel); \n",
397
    "        axs[0].set_title(r'$F={}\\mathrm{{MHz}}$'.format(Fsel))"
Christian Rohlfing's avatar
Christian Rohlfing committed
398
   ]
Christian Rohlfing's avatar
Christian Rohlfing committed
399
  },
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
400
  {
Christian Rohlfing's avatar
Christian Rohlfing committed
401
   "cell_type": "markdown",
402
403
404
405
406
407
408
   "metadata": {},
   "source": [
    "In dieser Demo kann beobachtet werden, wie sich die Ausgangsspannung verändert, je nachdem welcher Wert für $F$ gewählt wird. Für kleine Werte von $F$ wird die Ausgangsspannung gedämpft, während sie für größere Werte eine zur Eingangsspannung ähnliche Charakteristik aufweist."
   ]
  },
  {
   "cell_type": "markdown",
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
409
   "metadata": {},
Christian Rohlfing's avatar
Christian Rohlfing committed
410
   "source": [
411
    "___\n",
Christian Rohlfing's avatar
Christian Rohlfing committed
412
413
414
    "This notebook is provided as [Open Educational Resource](https://en.wikipedia.org/wiki/Open_educational_resources) (OER). Feel free to use the notebook for your own purposes. The code is licensed under the [MIT license](https://opensource.org/licenses/MIT). \n",
    "\n",
    "Please attribute the work as follows: \n",
415
    "*Christian Rohlfing, Übungsbeispiele zur Vorlesung \"Grundgebiete der Elektrotechnik 3 - Signale und Systeme\"*, gehalten von Jens-Rainer Ohm, 2020, Institut für Nachrichtentechnik, RWTH Aachen University."
Christian Rohlfing's avatar
Christian Rohlfing committed
416
   ]
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
435
   "version": "3.8.1"
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
436
437
438
  }
 },
 "nbformat": 4,
439
 "nbformat_minor": 4
Christian Rohlfing's avatar
- init  
Christian Rohlfing committed
440
}