aboutsummaryrefslogtreecommitdiff
path: root/jarrio/week10.bc
blob: 80a8fee02da5336620f31c59e068d5252837f395 (plain)
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
print "Daily Homework 10a\n"

print "Question 4\n"
#params
vbattery = 3.05
vchange = 2.9
ammeter = 1.7

bigr = vchange/ammeter
"emf "
vbattery
"internal resistance "
rtot = vbattery/ammeter
rtot - bigr
"circuit resistance "
bigr

print "\nDaily Homework 10b\n"

print "Question 1\n"
#params
r1 = 2
r2 = 5
r3 = 1
r4 = 7
r5 = 3
r6 = 3
r7 = 3

"RA "
r4+r3+1/(1/r1+1/r2)
"RB (open) "
r5 + r4 + r3 + 1/(1/(r6+r1) + 1/r2)
"RB (closed) "
r5 + 1/(1/r4+1/r7) + r3 + 1/(1/(r6+r1) + 1/r2)

print "Question 2\n"
print "Rlong^2\n"

print "Question 3\n"
# params
ratio = 10 # Ip = 10Is
# Without loss of generality, let Is = 1, and R2 = 1, so r = R1.
# IR = V
# 1(1+r) = V
# 10/(1/1 + 1/r) = V
# 1 + r = 10/(1 + 1/r)
# (1+r)(1+1/r) = 10
# r^2 + 2r + 1 = 10r
# r^2 - 8r + 1 = 0
b = 2 - ratio
(-b - sqrt(b^2 - 4*1*1))/2

print "Question 4\n"
#params
ammeter = 9

# clockwise loop rule on top loop
# ammeter - 3*i1 + 2*ammeter = 0
i1 = ammeter
print "I1 (A)\n"
i1

# branch rule
i2 = i1+ammeter
print "I2 (A)\n"
i2

# clockwise loop rule on bottom loop
# -2*ammeter + electromotive - 1*i2 = 0
electromotive = 2*ammeter + i2
print "Electromotive (V)\n"
electromotive

print "\nDaily Homework 10c\n"
print "Question 2\n"
print "C > A = E > B > D\n"

print "Question 3\n"
#params
c = 10 # uF
q = 30 # uC
r = 1.8 # kOhm
qtarget = 15 # uC

# c = q(t)/v(t) --> v(t) = q(t)/c
# dq(t)/dt = -I = -v(t)/r
# dq(t)/dt = -q(t)/cr
# q(t) = Ce^{-t/cr}
# C = q
# q(t) = qe^{-t/cr} = qtarget => -t/cr = ln(qtarget/q)

r = r*1000 # Ohm
qtarget = qtarget/10^6 # C
c = c/10^6 # F
q = q/10^6 # C

t = -c*r*l(qtarget/q)
print "Time (s)\n"
t

print "\nWeekly Homework 10\n"
print "Question 1\n"
#params
r1 = 2.5 # kOhm
r2 = 4.0 # kOhm
r3 = 5.0 # kOhm
v = 100 # V
# v = ir
# p = iv = v^2/r

pparallel = v^2 / (1/(1/r1 + 1/r2 + 1/r3))
pseries = v^2 / (r1 + r2 + r3)
pparallel/pseries

print "Question 2\n"
# I = ef/(r+R)
# P = I^2R = ef^2*R/(r+R)^2
# dP/dR = 0 = d/dR (ef^2*R/(r+R)^2)
# d/dR (R/(r+R)^2) = 0
# (r+R)/(r+R)^3 - 2R/(r+R)^3 = (r-R)/(r+R)^3 = 0
# r = R
print "Part A: R = r\n"

print "Part B\n"
# params
ef = 5 # V
r = 1.8 # Ohm
i = ef/(r+r)
print "Power (W)\n"
i^2*r

print "Question 3\n"
#params
bulbr = 6 # Ohm
r = .8 # Ohm
v = 1.5 # V

iopen = v/(r+bulbr)
print "I_open (A)\n"
iopen

iclosed = v/(r+bulbr/2) / 2 # because current is even between a and b
print "I_closed (A)\n"
iclosed

print "pct change\n"
100*(iclosed-iopen)/iopen

print "Question 4\n"
v = 24 # V
# No params. Effective resistance w/ open is 6Ohm and 6Ohm in parallel,
# giving 3Ohm
print "Part A - Ibat (A)\n"
v/3

print "Part B - dV (V)\n"
v/3

# the two pairs of parallel resistors = two effective resistors in
# parallel
print "Part C - Ibat (A)\n"
v / (1/(1/3 + 1/5) + 1/(1/3 + 1))

print "Part D - dV (V)\n"
0

print "Question 5\n"
v = 24 # V
i6 = v/10 # effective resistance calculation
i5 = v/15 # same
i10 = i5
i4 = i6

print "Currents (i6, i5, i10, i4)\n"
i6
i5
i10
i4

v6 = i6*6 # V = IR
v5 = i5*5
v10 = i10*10
v4 = i4*4
print "Voltages (v6, v5, v10, v4)\n"
v6
v5
v10
v4

print "Question 6\n"
#params
v = 150
rtot = 2 + 1/(1/20 + 1/5) + 4
itot = v/rtot
vparallel = itot / (1/20 + 1/5) # v through the parallel resistors
i20 = vparallel/20

print "I20 (A)\n"
i20

print "Question 7\n"

# 1/(1/4 + 1/12) = 3.
# 3 + 5 = 8
# 1/(1/8 + 1/24) = 6.
# Assume current goes clockwise.
# Loop: 12 - I*6 - 3 - I*3 = 0
# 9 = I*9 => I = 1A.
# Then, week10resistors.py has the solution
print "See source\n"

print "Question 8\n"
#params
tconstant = 7 # ms

print "Charge reduced to half (ms)\n"
-l(1/2)*tconstant

print "Energy reduced to half (ms)\n"
-l(1/sqrt(2))*tconstant

print "Question 9\n"
#params
c = 40 # uF
# The graph shows a reduction from 30V to 10V in 4ms, giving a time
# constant of
tconstant = 4/l(30/10) # ms
# tconstant = cr => r = tconstant/c
c = c/10^6 # F
tconstant = tconstant/1000 # s
r = tconstant/c
print "Resistance\n"
r

print "Question 10\n"
#params
c = .25 # uF
v = 70 # V
r1 = 25 # Ohm (the one the question asks about)
r2 = 150 # Ohm
q = c*v # uC
j = q*v/2
print "Energy dissipated (uJ)\n"
j*r1/(r1+r2)