import math
#variable declaration
sod=15#stator-core outer diameter
sid=10.05#stator-core inner diameter
rod=10.00#rotor-core outer diameter
rid=5#rotor-core inner diameter
a=8#axial lenght of the machine
b=1.20
ur=1000
#calculations
vs=(3.14/4)*((sod*sod)-(sid*sid))*a#volume of stator-core
vr=(3.14/4)*((rod*rod)-(rid*rid))*a#volume of rotor-core
va=(3.14/4)*((sid*sid)-(rod*rod))*a#volume of air-gap in the machine
ed=(.5*b*b)/(4*3.14*math.pow(10,-7))
e=ed*va*math.pow(10,-6)
edm=(.5*b*b)/(4*3.14*math.pow(10,-7)*ur)
es=edm*vs*math.pow(10,-6)
er=edm*vr*math.pow(10,-6)
kr=(vs+vr)/vs
ke=(es+er)/e
ratio=kr/ke
eratio=e/(es+er)
#result
print "Energy stored in air gap= ",e," Joules"
print "Energy stored in stator-core= ",round(es,2)," Joules"
print "Energy stored in rotor core= ",er," Joules"
print "Ratio of energy dtored in air-gap to that stored in the cores=",round(eratio)
import math
#variable declaration
n=800#turns
area=5*5#cross sectional area
i=1.25#amp
x=0.25#cm
l=0.402
#calculations
p=4*3.14*10**(-7)*area*10**(-4)/(0.5*10**(-2))
l=n**2*p
em=.5*i*i*l
W=-1*0.5*n**2*4*3.14*10**(-7)*area*10**(-4)*i**2/(0.5*10**(-2))**2
#result
print "a)i)coil inductance=",l,"H"
print " ii)field energy stored=",em,"J"
print "b)mechanical energy output=",W,"NW"
#variable declaration
lo=50#mH
xo=0.05#cm
r=0.5#ohm
x=0.075#cm
i2=3#A
x2=0.15#cm
#calculation
l1=2*lo/(1+(x/xo))
lambda1=l1*i2*10**(-3)
W=0.5*l1*i2**2*10**(-3)
l2=2*lo/(1+(x2/xo))
lambda2=l2*i2*10**(-3)
w2=0.5*i2*(lambda1-lambda2)
#result
print "a)magnetic stored energy=",W,"J"
print "b)change in magnetic stored energy=",w2,"J"
#variable declaration
rc=0.5#ohm
v=3#V
i=6#A
l1=40#mH
l2=25#mH
wfld=0.5*l2*i*i*0.001
delE=0.5*i*i*0.001*(l1-l2)
#result
print "a)magnetic stored energy=",wfld,"J"
print "b)change in magnetic store energy=",delE,"J"