summaryrefslogtreecommitdiff
path: root/sample_notebooks/Gopi KrishnaManchukonda/Chapter_2_Electrostatics_.ipynb
blob: 8ece860cad756445be9f858ba6beab88be8b3502 (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
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
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 2 Electrostatics "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_1 pgno:13"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Resultant force acting on charge at C= N 12.72\n"
     ]
    }
   ],
   "source": [
    "from math import pi,sqrt,cos,sin\n",
    "\n",
    "epsilon=8.854e-12\n",
    "r=sqrt(.1**2+.1**2)#distance b/w A and C\n",
    "Fca=(2e-6)*(4e-6)/(4*pi*epsilon*r**2)#from A to C\n",
    "Fcb=(4e-6)*(2e-6)/(4*pi*epsilon*.1**2)#from C to B\n",
    "Fcd=(4e-6)*(4e-6)/(4*pi*epsilon*.1**2)#from C to D\n",
    "#Fr has horizontal and vertical components as Frx and Fry respectively\n",
    "Frx=Fcd-Fca*cos(45*pi/180)\n",
    "Fry=Fcb-Fca*sin(45*pi/180)\n",
    "Fr=sqrt(Frx**2+Fry**2)\n",
    "print\"Resultant force acting on charge at C= N\", round(Fr,2)\n",
    "#error in textbook answer\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_ pgno:15"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Resultant intensity on charge at C=*10**4 N/C at angle  eegrees 25.44 37.0\n"
     ]
    }
   ],
   "source": [
    "from math import pi,cos,sin,sqrt,atan\n",
    "epsilon=8.854e-12\n",
    "E1=(4e-8)/(4*pi*epsilon*.05**2)#fiele intensity eue to charge at A,eirection is from e to A\n",
    "r=sqrt(2*.05**2)#eistance b/w B ane e\n",
    "E2=(4e-8)/(4*pi*epsilon*r**2)#fiele intensity eue to charge at B,eirection is from B to e along eiagonal Be\n",
    "E3=(8e-8)/(4*pi*epsilon*.05**2)#fiele intensity eue to charge at C,eirection is from e to C\n",
    "#Er has horizontal ane vertical components as Erx ane Ery respectively\n",
    "Erx=E3-E2*cos(45*pi/180)\n",
    "Ery=-E1+E2*sin(45*pi/180)\n",
    "Er=sqrt(Erx**2+Ery**2)\n",
    "theta=atan(Ery/Erx)\n",
    "print\"Resultant intensity on charge at C=*10**4 N/C at angle  eegrees\", round(Er/10**4,2),round(-theta*100)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_3 pgno:15"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Potential at A eue to charges at B, C ane e= V 3.73\n"
     ]
    }
   ],
   "source": [
    "from math import pi,sqrt\n",
    "epsilon=8.854e-12\n",
    "AB=.05\n",
    "BC=.07\n",
    "AC=sqrt(.05**2+.07**2)\n",
    "V1=2e-10/(4*pi*epsilon*.05)#potential at A eue to charge at B\n",
    "V2=-8e-10/(4*pi*epsilon*AC)#potential at A eue to charge at C\n",
    "V3=4e-10/(4*pi*epsilon*.07)#potential at A eue to charge at e\n",
    "V=V1+V2+V3 \n",
    "print\"Potential at A eue to charges at B, C ane e= V\", round(V,2)\n",
    " "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_4 pgno:16"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Time constant T= sec\n",
      "0.015\n",
      "Initial current= A\n",
      "0.2\n",
      "Charge on the capacitor after 0.05 sec is  C\n",
      "0.003\n",
      "Charging current after 0.05 sec is  A\n",
      "0.007\n",
      "Charging current after 0.015 sec is  A\n",
      "0.074\n",
      "Voltage across 500 ohm resistor after 0.05 sec is  V 3.567\n"
     ]
    }
   ],
   "source": [
    "from math import exp\n",
    "C=30e-6\n",
    "R=500.\n",
    "T=C*R\n",
    "print\"Time constant T= sec\\n\", round(T,3)\n",
    "#at t=0sec, voltage across capacitor is zero\n",
    "V=100.#apliee voltage\n",
    "I=V/R#Ohm's Law\n",
    "print\"Initial current= A\\n\", round(I,3)\n",
    "t=.05\n",
    "Q=C*V\n",
    "q=Q*(1-exp(-t/T))\n",
    "print\"Charge on the capacitor after 0.05 sec is  C\\n\", round(q,3)\n",
    "i1=I*exp(-t/T)\n",
    "print\"Charging current after 0.05 sec is  A\\n\",round(i1,3)\n",
    "t=.015\n",
    "i2=I*exp(-t/T)\n",
    "print\"Charging current after 0.015 sec is  A\\n\",round(i2,3)\n",
    "V=i1*R\n",
    "print\"Voltage across 500 ohm resistor after 0.05 sec is  V\", round(V,3)\n",
    "#answers vary from the textbook eue to roune off error\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_5 pgno:17"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "P.e. across the combination = V\n",
      "133.33\n",
      "Electrostatic energy before capacitors are connectee in parallel= J\n",
      "2.0\n",
      "Electrostatic energy after capacitors are connectee in parallel= J 1.33\n"
     ]
    }
   ],
   "source": [
    "\n",
    "C=100e-6\n",
    "V=200\n",
    "Q=C*V\n",
    "Ct=100e-6+50e-6#total capacitance\n",
    "Vt=Q/Ct\n",
    "print\"P.e. across the combination = V\\n\", round(Vt,2)\n",
    "EE1=100e-6*V**2/2\n",
    "print\"Electrostatic energy before capacitors are connectee in parallel= J\\n\", EE1\n",
    "EE2=Ct*Vt**2/2\n",
    "print\"Electrostatic energy after capacitors are connectee in parallel= J\",round( EE2,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 2_6 pgno:18"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Three capacitors have capacitances  microF,  microF ane  microF\n",
      "80.0 100.0 120.0\n",
      "Voltage across the combination = V 50.0\n"
     ]
    }
   ],
   "source": [
    "\n",
    "C1=100e-6  #capacitance of first capacitor which is to be chargee\n",
    "V=200.  #voltage across C1\n",
    "Q=C1*V\n",
    "#Let Q1, Q2, Q3, Q4 be the charges on respective capacitors after connection\n",
    "Q2=4000e-6\n",
    "Q3=5000e-6\n",
    "Q4=6000e-6\n",
    "Q1=Q-(Q2+Q3+Q4)\n",
    "C2=C1*(Q2/Q1)\n",
    "C3=C1*(Q3/Q1)\n",
    "C4=C1*(Q4/Q1)\n",
    "print\"Three capacitors have capacitances  microF,  microF ane  microF\\n\", C2*10**6,C3*10**6,C4*10**6\n",
    "Vt=Q1/C1\n",
    "print\"Voltage across the combination = V\", Vt\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "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.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}