import math
from math import sqrt,pi,log
#given parameters
Rf=100 #resistance in ohms
Lf=25 #inductance
Ra=0.25 #armature resistance in ohms
Laq=0.02 #inductance in Henry
Kg=100 #in volts per field ampere at rated speed
Ll=0.15 #load-inductance
V=200 #field circuit voltage
Rl=1 #load resistance
#calculations
tow=Lf/Kg #field circuit time constance
log(0.1)
t=2.30/4
Towat=(Ll+Laq)/(Rl+Ra)
print 'time required to rise to 90% value is',t,'sec'
print 'Armature current as a function of time is',Towat,'sec'
import math
from math import pi,sqrt,exp
#Given parameters
Xd=0.9 #in pu
Vt=1.0 #prefault condition
Ia=1.0
Xd1=0.4
Xd2=0.2
Ta=0.2
Td1=4.0
Td2=0.6
t=0.1 #time given
x=Ia*math.cos(-25.8*pi/180) #rectangular to polar conversion
y=Ia*math.sin(-25.8*pi/180)
X=complex(x,y)
x1=Xd*math.cos(90*pi/180)
y1=Xd*math.sin(90*pi/180)
X1=complex(x1,y1)
A=Vt+(X*X1)
Ei=1.39*math.cos(0.81*pi/180)
Angle=1.39*math.sin(0.81*pi/180)
(x2,y2)=(Xd1 ,90)
X2=complex(x2,y2)
(Ei2,Angle1)=(1.17,0.36)
(x3,y3)=(Xd2 ,90)
X3=complex(x3,y3)
(Ei2,Angle2)=(1.08,0.10)
Idc=sqrt(2)*(Ei2/Xd2) #initial value of the dc offset current
Td1=(Xd1/Xd)*Td1
Td2=(Xd2/Xd1)*Td2
Isc1=sqrt(2)*(Td1+1.29*exp(-0.562*0.1)+2.42*exp(-3.3*0.1))+7.78*exp(-5*0.1)
Isc=sqrt(4.75**2+4.72**2)
Isc=round(Isc,1)
Idc=round(Idc,2)
print 'dc offset current=',Idc,'pu'
print 'RMS Value at t=0.1sec',Isc,'pu'