1.. _networks: 2 3======== 4Networks 5======== 6 7Lcapy supports one-port and two-port networks. 8 9 10 11One-port networks 12================= 13 14One-port networks are creating by combining one-port components in 15series or parallel, for example, here's an example of resistors in 16series 17 18 >>> from lcapy import R 19 >>> R1 = R(10) 20 >>> R2 = R(5) 21 >>> Rtot = R1 + R2 22 >>> Rtot 23 R(10) + R(5) 24 25Here `R(10)` creates a 10 ohm resistor and this is assigned to the 26variable `R1`. Similarly, `R(5)` creates a 5 ohm resistor and this is 27assigned to the variable `R2`. `Rtot` is the name of the network 28formed by connecting `R1` and `R2` in series. 29 30 >>> Rtot.draw() 31 32.. image:: examples/networks/rseries.png 33 :width: 4cm 34 35 36Network attributes 37------------------ 38 39Each network has a number of attributes, including: 40 41- `Voc` s-domain open-circuit voltage 42 43- `Isc` s-domain short-circuit current 44 45- `I` s-domain current through network terminals (zero by definition) 46 47- `Z` s-domain impedance 48 49- `Y` s-domain admittance 50 51- `voc` t-domain open-circuit voltage 52 53- `isc` t-domain short-circuit current 54 55- `isc` t-domain current through network terminals (zero by definition) 56 57- `y` t-domain impulse response of admittance 58 59- `z` t-domain impulse response of impedance 60 61- `is_dc` DC network 62 63- `is_ac` AC network 64 65- `is_ivp` initial value problem 66 67- `is_causal` causal response 68 69 70 71Here's an example: 72 73 >>> from lcapy import R, V 74 >>> n = V(20) + R(10) 75 >>> n.Voc 76 20 77 ── 78 s 79 >>> n.voc 80 20 81 >>> n.Isc 82 2 83 ─ 84 s 85 >>> n.isc 86 2 87 >>> n.Z 88 10 89 >>> n.Y 90 1/10 91 92.. image:: examples/networks/VRseries.png 93 :width: 4cm 94 95 96Network simplification 97---------------------- 98 99A network can be simplified (if possible) using the `simplify` method. 100For example, here's an example of a parallel combination of resistors. 101Note that the parallel operator is `|` instead of the usual `||`. 102 103 >>> from lcapy import * 104 >>> Rtot = R(10) | R(5) 105 >>> Rtot 106 R(10) | R(5) 107 >>> Rtot.simplify() 108 R(10/3) 109 110The result can be performed symbolically, for example, 111 112 >>> from lcapy import * 113 >>> Rtot = R('R_1') | R('R_2') 114 >>> Rtot 115 R(R_1) | R(R_2) 116 >>> Rtot.simplify() 117 R(R_1*R_2/(R_1 + R_2)) 118 >>> Rtot.simplify() 119 R(R₁) | R(R₂) 120 121Here's another example using inductors in series 122 123 >>> from lcapy import * 124 >>> L1 = L(10) 125 >>> L2 = L(5) 126 >>> Ltot = L1 + L2 127 >>> Ltot 128 L(10) + L(5) 129 >>> Ltot.simplify() 130 L(15) 131 132Finally, here's an example of a parallel combination of capacitors 133 134 >>> from lcapy import * 135 >>> Ctot = C(10) | C(5) 136 >>> Ctot 137 C(10) | C(5) 138 >>> Ctot.simplify() 139 C(15) 140 141 142Norton and Thevenin transformations 143----------------------------------- 144 145A Norton or Thevenin equivalent network can be created using the 146`norton` or `thevenin` methods. For example, 147 148 >>> from lcapy import Vdc, R 149 >>> a = Vdc(1) + R(2) 150 >>> a.norton() 151 G(1/2) | Idc(1/2) 152 153 154Network schematics 155================== 156 157One port networks can be drawn with a horizontal layout. Here's an example: 158 159 >>> from lcapy import R, C, L 160 >>> ((R(1) + L(2)) | C(3)).draw() 161 162Here's the result: 163 164.. image:: examples/networks/pickup.png 165 :width: 5cm 166 167The s-domain model can be drawn using: 168 169 >>> from lcapy import R, C, L 170 >>> ((R(1) + L(2)) | C(3)).smodel().draw() 171 172This produces: 173 174.. image:: examples/networks/pickup-s.png 175 :width: 5cm 176 177Internally, Lcapy converts the network to a netlist and then draws the 178netlist. The netlist can be found using the netlist method, for example, 179 180 >>> from lcapy import R, C, L 181 >>> print(((R(1) + L(2)) | C(3)).netlist()) 182 183yields:: 184 185 W 1 3; right, size=0.5 186 W 3 4; up, size=0.4 187 W 3 5; down, size=0.4 188 W 6 2; right, size=0.5 189 W 6 7; up, size=0.4 190 W 6 8; down, size=0.4 191 R 4 9 1; right 192 W 9 10; right, size=0.5 193 L 10 7 2 0; right 194 C 5 8 3 0; right 195 196Note, the components have anonymous identifiers. 197 198 199To create a schematic with multiple components in parallel, use `Par`. 200For example, 201 202.. literalinclude:: examples/networks/par3.py 203 204 205.. image:: examples/networks/par3.png 206 :width: 3cm 207 208 209 210Network analysis examples 211========================= 212 213 214Series R-C network 215------------------ 216 217 218.. literalinclude:: examples/netlists/series-RC1-Z.py 219 220 221.. image:: examples/netlists/series-RC1-Z.png 222 :width: 15cm 223 224 225.. literalinclude:: examples/netlists/series-VRC1-isc.py 226 227.. image:: examples/netlists/series-VRC1-isc.png 228 :width: 15cm 229 230 231 232Series R-L network 233------------------ 234 235 236.. literalinclude:: examples/netlists/series-RL1-Z.py 237 238 239.. image:: examples/netlists/series-RL1-Z.png 240 :width: 15cm 241 242 243.. literalinclude:: examples/netlists/series-VRL1-isc.py 244 245.. image:: examples/netlists/series-VRL1-isc.png 246 :width: 15cm 247 248 249Series R-L-C network 250-------------------- 251 252 253.. literalinclude:: examples/netlists/series-RLC3-Z.py 254 255 256.. image:: examples/netlists/series-RLC3-Z.png 257 :width: 15cm 258 259 260.. literalinclude:: examples/netlists/series-VRLC1-isc.py 261 262.. image:: examples/netlists/series-VRLC1-isc.png 263 :width: 15cm 264 265 266 267 268Parallel R-L-C network 269---------------------- 270 271 272.. literalinclude:: examples/netlists/parallel-RLC3-Z.py 273 274 275.. image:: examples/netlists/parallel-RLC3-Z.png 276 :width: 15cm 277 278 279.. literalinclude:: examples/netlists/parallel-IRLC1-voc.py 280 281.. image:: examples/netlists/parallel-IRLC1-voc.png 282 :width: 15cm 283 284