-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab4.py
More file actions
32 lines (23 loc) · 818 Bytes
/
Copy pathLab4.py
File metadata and controls
32 lines (23 loc) · 818 Bytes
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
Web VPython 3.2
eps0 = 8.85E-12 # F/m
Q = 10E-3 # C Coulombs, charge on the plates
R = 5E-2 # m, radius of the disks
d = 2*R #m, distance between disks
sigma = Q/(pi*(R**2)) # C/m^2, surface charge density
N = 100 # number of divisions from z = 0 to z = d
deltaz = d/N
# initializations
i = 0
z = 0
deltaV = 0
while i < N : # computationally integrating from the positive plate at z = 0 to the negative plate at z = d
Ez_pos = (sigma/(2*eps0)) * (1 - z/sqrt(R**2 + z**2))
Ez_neg = (sigma/(2*eps0)) * (1 - (d-z)/sqrt(R**2 + (d-z)**2))
Ez = Ez_pos + Ez_neg # Total field
deltaV = deltaV + Ez * deltaz
z = z - deltaz
i = i + 1
C = Q/deltaV
# multiply each by 1E9 to get nF
print('calculated capacitance (nF): ', C*1E9)
print('approximate capacitance (nF): ', (eps0*pi*R**2/d)*1E9 )