Debian Codegraph @

doc/source/examples/interactive/Interactive Mismatched Line.ipynb

raw
1 {
2 "cells": [
3 {
4 "cell_type": "markdown",
5 "metadata": {},
6 "source": [
7 "# Interactive Mismatched Line"
8 ]
9 },
10 {
11 "cell_type": "markdown",
12 "metadata": {},
13 "source": [
14 "## Intro"
15 ]
16 },
17 {
18 "cell_type": "markdown",
19 "metadata": {},
20 "source": [
21 "This is a demonstration of using IPythons `interact` function with some of `skrf`'s network creation methods."
22 ]
23 },
24 {
25 "cell_type": "markdown",
26 "metadata": {},
27 "source": [
28 "<div class=\"alert alert-success\">\n",
29 "As of IPython 2.0, the widgets in this notebook won't show up on http://nbviewer.ipython.org. To view the widgets and interact with them, you will need to download this notebook and run it with an IPython Notebook server.\n",
30 "</div>"
31 ]
32 },
33 {
34 "cell_type": "code",
35 "execution_count": null,
36 "metadata": {},
37 "outputs": [],
38 "source": [
39 "from IPython.display import YouTubeVideo\n",
40 "\n",
41 "YouTubeVideo('JyYi_1SswXs',width=700, height=580)\n"
42 ]
43 },
44 {
45 "cell_type": "code",
46 "execution_count": null,
47 "metadata": {},
48 "outputs": [],
49 "source": [
50 "import matplotlib.pyplot as plt\n",
51 "from ipywidgets import interact\n",
52 "\n",
53 "%matplotlib inline\n",
54 "\n",
55 "import skrf as rf\n",
56 "from skrf import Frequency\n",
57 "from skrf.media import DistributedCircuit\n",
58 "\n",
59 "rf.stylely()\n",
60 "\n",
61 "\n",
62 "# define a frequency object\n",
63 "freq = Frequency(0,10,1001,'GHz')\n",
64 "\n",
65 "# create a Media object for RG-58, based on distributed ckt values\n",
66 "rg58 = DistributedCircuit(frequency = freq,\n",
67 " C =93.5e-12,#F/m\n",
68 " L =273e-9, #H/m\n",
69 " R =0,#53e-3, #Ohm/m\n",
70 " G =0, #S/m\n",
71 " )"
72 ]
73 },
74 {
75 "cell_type": "markdown",
76 "metadata": {},
77 "source": [
78 "## Mismatched Line"
79 ]
80 },
81 {
82 "cell_type": "markdown",
83 "metadata": {},
84 "source": [
85 "This demonstrates the response of a mismatched transmission line of a given length. Specifically, a line of electrical length $d$ with characteristic impedance $z_0$ is embedded in the coaxial environment (RG-58 ) with $z_0 \\approx 54 \\Omega$. The resultant S-parameters are plotted in log mag and on the smith chart. "
86 ]
87 },
88 {
89 "cell_type": "markdown",
90 "metadata": {},
91 "source": [
92 "### Log Mag"
93 ]
94 },
95 {
96 "cell_type": "code",
97 "execution_count": null,
98 "metadata": {},
99 "outputs": [],
100 "source": [
101 "def func(d=180,z0=54):\n",
102 " ntwk =rg58.line(d=d,unit='deg',z0=z0)\n",
103 " ntwk.renormalize(rg58.z0)\n",
104 " ntwk.plot_s_db(1,0)\n",
105 " ntwk.plot_s_db(0,0)\n",
106 " plt.ylim(-50,20)\n",
107 " plt.draw()\n",
108 " plt.show()\n",
109 "\n",
110 "interact(func, d= (0,360,10),z0=(10,200,1),embed=True);"
111 ]
112 },
113 {
114 "cell_type": "markdown",
115 "metadata": {},
116 "source": [
117 "### Smith Chart"
118 ]
119 },
120 {
121 "cell_type": "code",
122 "execution_count": null,
123 "metadata": {},
124 "outputs": [],
125 "source": [
126 "\n",
127 "def func(d=180,z0=54):\n",
128 " ntwk =rg58.line(d=d,unit='deg',z0=z0)\n",
129 " ntwk.renormalize(rg58.z0)\n",
130 " ntwk.plot_s_smith(1,0)\n",
131 " ntwk.plot_s_smith(0,0)\n",
132 " plt.draw()\n",
133 " plt.show()\n",
134 "\n",
135 "\n",
136 "interact(func, d= (0,180,10),z0=(10,200,1),embed=True);"
137 ]
138 },
139 {
140 "cell_type": "code",
141 "execution_count": null,
142 "metadata": {},
143 "outputs": [],
144 "source": []
145 }
146 ],
147 "metadata": {
148 "anaconda-cloud": {},
149 "kernelspec": {
150 "display_name": "Python 3 (ipykernel)",
151 "language": "python",
152 "name": "python3"
153 },
154 "language_info": {
155 "codemirror_mode": {
156 "name": "ipython",
157 "version": 3
158 },
159 "file_extension": ".py",
160 "mimetype": "text/x-python",
161 "name": "python",
162 "nbconvert_exporter": "python",
163 "pygments_lexer": "ipython3",
164 "version": "3.8.10"
165 }
166 },
167 "nbformat": 4,
168 "nbformat_minor": 1
169 }