#Chapter 2,Example 2.1 Page 78
import math
#(i) Determine volatge regulation
C = 0.06 # micro farad
I = 1. #mA
f = 150. #Hz
n = 10.
V = (1./(f*C))*((2.*n**3./3.)+(n**2./2.))
perc = (V*100.)/(2.*10.*100.)
print'%s %d %s' % (" (ia) Volatge regulation =",round(V)," kV \n ")
print'%s %d %s' % (" (ib) percentage volatge regulation =",round(perc),"% \n ")
#(ii) Ripple volatge
delV = (1./(f*C))*(n*(n+1.)/2.)
perc = (delV*100)/(2*10*100)
print'%s %.1f %s' % (" (iia) The ripple votage = ",delV," kV \n ")
print'%s %.1f %s' % (" (iib) percentage ripple votage =",perc,"% \n")
#(iii) Optimum no. of stages
Vmax = 100.
I = 10.**-3.
OnS = math.sqrt(Vmax*f*C*10**-6*10**3/I)
#(iv) Maximum output volatge
Vout = OnS*(4./3.)*Vmax
print'%s %d %s' % (" (iii) Optimum no. of stages = ",OnS,"\n")
print'%s %d %s' % (" (iv) Maximum output volatge =",Vout,"KV\n ")
# Answers may vary due to round off error
#Chapter 2,Example 2.2 Page 79
# based on the circuit Fig.Ex.2.2
V = 100. # kVA
R = (1./100.)*(200.**2./0.1) # Resistance of transformer
r = (5./100.)*(200.**2./0.1) # reactance of transformer
print'%s %d %s' % (" Resistance of transformer =",R/1000,"K ohm \n ")
print'%s %d %s' % (" Reactance of transformer =",r/1000,"K ohm \n ")
rC = 400./0.5 # Reactance of capacitor
rI = 20. # Inductive reactance
ArI = rC-rI # Additional inductive reactance
Ic = ArI*1000./314. # inductance required
TrC = 8. # total reactance in cercuit in Kohm
I = 0.5
Vsec = I*TrC # Secondary voltage
Vp = 4.*(250./200.) # primary voltage
print'%s %d %s' % (" Reactance of capacitor = ",rC," K ohm \n ")
print'%s %d %s' % (" Inductive reactance = ",rI," ohm \n ")
print'%s %d %s' % (" Additional inductive reactance = ",ArI,"K ohm\n ")
print'%s %d %s' % (" Inductive required = ",Ic," H \n ")
print'%s %d %s' % (" Total reactance in cercuit = ",TrC," K ohm \n ")
print'%s %d %s' % (" Secondary voltage = ",Vsec,"kV \n ")
print'%s %d %s' % (" Secondary voltage = ",Vp," volts \n ")
# Answers may vary due to round off error