1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Chapter 12: Resistance and DC Circuits"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 12.1, Page 237"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Magnitude, I4 = -3 A\n"
]
}
],
"source": [
"#Initialization\n",
"i1=8 #current in Amp\n",
"i2=1 #current in Amp\n",
"i3=4 #current in Amp\n",
"\n",
"#Calculation\n",
"i4=i2+i3-i1 #current in Amp\n",
"\n",
"#Results\n",
"print'Magnitude, I4 = %d A'%i4"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 12.2, Page 239"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#Initialization\n",
"e=12 #EMF source in volt\n",
"v1=3 #node voltage\n",
"v3=3 #node voltage\n",
"\n",
"#Calculation\n",
"v2=v1+v3-e #node voltage\n",
"\n",
"#Results\n",
"print'V2 = %d V'%v2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 12.4, Page 242"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Voc = 10 V\n",
"R = 100 ohm\n"
]
}
],
"source": [
"import numpy as np\n",
"\n",
"#We have used method II for solving our problem by using simultaneous equations\n",
"\n",
"a = np.array([[25,-2],[400,-8]]) \n",
"b = np.array([[50],[3200]])\n",
"c=np.linalg.solve(a,b)\n",
"\n",
"print'Voc = %d V'%c[0]\n",
"print'R = %d ohm'%c[1]\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 12.5, Page 244"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Voltage, V = 7.14\n"
]
}
],
"source": [
"#Initialization\n",
"r1=100 #Resistance in Ohm\n",
"r2=200 #Resistance in Ohm\n",
"r3=50 #Resistance in Ohm\n",
"v1=15 #voltage source\n",
"v2=20 #voltage source\n",
"\n",
"#Calculation\n",
"#Considering 15 V as a source & replace the other voltage source by its internal resistance,\n",
"r11=(r2*r3)*(r2+r3)**-1 #resistance in parallel\n",
"v11=v1*(r11/(r1+r11)) #voltage\n",
"#Considering 20 V as a source & replace the other voltage source by its internal resistance,\n",
"r22=(r1*r3)*(r1+r3)**-1 #resistance in parallel\n",
"v22=v2*(r22/(r2+r22)) #voltage\n",
"\n",
"#output of the original circuit\n",
"v33=v11+v22\n",
"\n",
"\n",
"\n",
"#Results\n",
"print'Voltage, V = %.2f'%v33"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 12.6, Page 246"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Output Current, I = 1.67 A\n"
]
}
],
"source": [
"#Initialization\n",
"r1=10 #Resistance in Ohm\n",
"r2=5 #Resistance in Ohm\n",
"v2=5 #voltage source\n",
"i=2 #current in Amp\n",
"\n",
"#Calculation\n",
"#Considering 5 V as a source & replace the current source by its internal resistance,\n",
"i1=v2*(r1+r2)**-1 #current using Ohms law\n",
"#Considering current source & replace the voltage source by its internal resistance,\n",
"r3=(r1*r2)*(r1+r2)**-1 #resistance in parallel\n",
"v3=i*r3 #voltage using Ohms law\n",
"i2=v3*r2**-1 #current using Ohms law\n",
"i3=i1+i2 #total current\n",
"\n",
"#Results\n",
"print'Output Current, I = %.2f A'%i3"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 12.8, Page 251"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"V2 = 33.04 V\n",
"V3 = 43.15 V\n",
"Current, I1 = 1.73 A\n"
]
}
],
"source": [
"import numpy as np\n",
"r=25 #resistance in ohm\n",
"\n",
"#We have used for solving our problem by using simultaneous equations\n",
"\n",
"a = np.array([[(-13*60**-1),(1*20**-1)],[(1*60**-1),(-9*100**-1)]]) \n",
"b = np.array([[-5],[-100*30**-1]])\n",
"c=np.linalg.solve(a,b)\n",
"i1=c[1]/r #required current\n",
"\n",
"print'V2 = %.2f V'%c[0] #wrong answer in textbook\n",
"print'V3 = %.2f V'%c[1] #wrong answer in textbook\n",
"print'Current, I1 = %.2f A'%i1\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example 12.9, Page 253"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I1 = 326 mA\n",
"I2 = 33 mA\n",
"I3 = 53 mA\n",
"Voltage, Ve = 0.197 V\n"
]
}
],
"source": [
"import numpy as np\n",
"re=10 #resistance in ohm\n",
"\n",
"#We have used for solving our problem by using simultaneous equations\n",
"\n",
"a = np.array([[(-160),(20), (30)],[(20),(-210), (10)], [(30),(10), (-190)]]) \n",
"b = np.array([[-50],[0],[0]])\n",
"c=np.linalg.solve(a,b)\n",
"ve=re*(c[2]-c[1])\n",
"\n",
"print'I1 = %d mA'%(c[0]*10**3) #current I1\n",
"print'I2 = %d mA'%(c[1]*10**3) #current I2\n",
"print'I3 = %d mA'%(c[2]*10**3) #current I3\n",
"print'Voltage, Ve = %.3f V'%ve\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [Root]",
"language": "python",
"name": "Python [Root]"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
|