In [4]:

```
#Chapter 2, Example 5, page 65
#Calculate the maximum field at the sphere surface
#Calulating Field at surface E based on figure 2.31 and table 2.3
from math import pi
Q1 = 0.25
e0 = 8.85418*10**-12 #Epselon nought
RV1= ((1/0.25**2)+(0.067/(0.25-0.067)**2)+(0.0048/(0.25-0.067)**2))
RV2= ((0.25+0.01795+0.00128)/(0.75-0.067)**2)
RV= RV1+RV2
E = (Q1*RV)/(4*pi*e0*10**10)
print"Maximum field = V/m per volt",E
#Answers vary due to round off error
```

In [12]:

```
#Chapter 2, Exmaple 6, page 66
#calculation based on figure 2.32
#(a)Charge on each bundle
print"Part a\t"
req = (0.0175*0.45)**0.5
print"Equivalent radius = m ", req
from math import log
from math import pi
V = 400*10**3 #Voltage
H = 12. #bundle height in m
d = 9. #pole to pole spacing in m
e0 = 8.85418*10**-12 #Epselon nought
Hd = ((2*H)**2+d**2)**0.5#2*H**2 + d**2
Q = V*2*pi*e0/(log((2*H/req))-log((Hd/d)))
q = Q/2
print"Charge per bundle = uC/m ",Q #micro C/m
print"Charge per sunconducter = uC/m ",q #micro C/m
#(b part i)Maximim & average surface feild
print"\tPart b"
print"\tSub part 1\t"
r = 0.0175 #subconductor radius
R = 0.45 #conductor to subconductor spacing
MF = (q/(2*pi*e0))*((1/r)+(1/R)) # maximum feild
print"Maximum feild = V/m \t",MF
MSF = (q/(2*pi*e0))*((1/r)-(1/R)) # maximum surface feild
print"Maximum feild = V/m \t",MSF
ASF = (q/(2*pi*e0))*(1/r) # Average surface feild
print"Maximum feild = V/m \t",ASF
#(b part ii) Considering the two sunconductors on the left
print"\tSub part 2\t"
#field at the outer point of subconductor #1
drO1 = 1/(d+r)
dRrO1 = 1/(d+R+r)
EO1 = MF -((q/(2*pi*e0))*(drO1+dRrO1))
print"EO1 = V/m \t",EO1
#field at the outer point of subconductor #2
drO2 = 1/(d-r)
dRrO2 = 1/(d-R-r)
EO2 = MF -((q/(2*pi*e0))*(dRrO2+drO2))
print"EO2 = V/m \t",EO2
#field at the inner point of subconductor #1
drI1 = 1/(d-r)
dRrI1 = 1/(d+R-r)
EI1 = MSF -((q/(2*pi*e0))*(drI1+dRrI1))
print"EI1 = V/m \t",EI1
#field at the inner point of subconductor #2
drI2 = 1/(d+r)
dRrI2 = 1/(d-R+r)
EI2 = MSF -((q/(2*pi*e0))*(dRrI2+drI2))
print"EI2 = V/m \t",EI2
#(part c)Average of the maximim gradient
print"\tPart c\t"
Eavg = (EO1+EO2)/2
print"The average of the maximum gradient = V/m \t",Eavg
#Answers might vary due to round off error
```

In [4]:

```
#Chapter 2, Exmaple 7, page 69
#Electric feild induced at x
from math import pi
e0 = 8.85418*10**-12 #Epselon nought
q = 1 # C/m
C = (q/(2*pi*e0))
#Based on figure 2.33
E = C-(C*(1./3.+1./7.))+(C*(1+1./5.+1./9.))+(C*(1./5.+1./9.))-(C*(1./3.+1./7.))
print"Electric Feild = V/m \t",E
#Answers might vary due to round off error
```

In [14]:

```
#Chapter 2, Exmaple 8, page 70
#Calculate the volume of the insulator
#Thinkness of graded design
from math import e
from math import pi
V = 150*(2)**0.5
Ebd = 50
T = V/Ebd
print"\nThickness of graded design= cm ",T
#Based on figure 2.24
r = 2 # radius of the conductor
l = 10 #length of graded cylinder; The textbook uses 10 instead of 20
zr = l*(T+r)
print"Curve = cm**2 ",zr
#Volume of graded design V1
V1 = 4*pi*zr*(zr-r)
print"V1 = cm**3 ",V1 #Unit is wrong in the textbook
#Thickness of regular design as obtained form Eq.2.77
pow = V/(2*Ebd)
t = 2*(e**pow-1)
print"Thickness of regular design = cm ",t
#Volume of regular design V2
V2 = pi*((2+t)**2-4)*10
print"V2 = cm**3 ",round(V2,2)#unit not mentioned in textbook
#Answers may vary due to round off error
```

In [15]:

```
#Chapter 2, Exmaple 11, page 75
#Calculate the potential within the mesh
#Based on figure 2.38(b)
#equations are obtained using Eq.2.46
import numpy
from numpy import linalg
A1 = 1/2*(0.54+0.16)
A2 = 1/2*(0.91+0.14)
S = numpy.matrix([[0.5571, -0.4571, -0.1],[-0.4751, 0.828, 0.3667],[-0.1, 0.667, 0.4667]])
#By obtaining the elements of the global stiffness matrix(Sadiku,1994)
#and by emplying the Eq.2.49(a)
S1 = numpy.matrix([[1.25, -0.014],[-0.014, 0.8381]])
S2 = numpy.matrix([[-0.7786, -0.4571],[-0.4571, -0.3667]])
Phi13 = numpy.matrix([[0], [10]])
val1 = S2*Phi13
Phi24 = val1/S1
print"The values of Phi2 and Phi4 are:",-Phi24
#Answers may vary due to round of error
```