# a
# parameter values
import math
Kp = 0.5; # V/rad
Ka = 100.; # V/V
Km = 2.*10.**-4. ; # lb-ft/V
F = 1.5*10.**-4.; # lb-ft/rad/s
J = 10.**-5. # slug-ft**2
K = Kp*Ka*Km ; # loop propotional gain
dr = F/(2.*math.sqrt(K*J)); # damping ratio
wn = math.sqrt(K/J);
ts = 5./(dr*wn);
wd = wn*math.sqrt(1. - dr**2.); # frequency at which damped oscillations occur
print '%s' %("a")
print '%s %.2f' %("damped oscillations occur at a frequency = ",wd)
print '%s %.2f' %("damping ratio = ",dr)
# b
Tl = 10.**-3.; # load disturbance (lb-ft)
e = Tl/K; # position lag error
print '%s' %("b")
print '%s %.2f' %("position lag error (in rad) = ",e)
# c
KaNew = (e/0.025)*Ka; # new loop gain
print '%s' %("c")
print '%s %.2f' %("new loop gain for which the position lag error is equal to 0.025rad = ",KaNew)
# d
drNew = F/(2.*math.sqrt(Kp*KaNew*Km*J)); # new damping ratio
print '%s' %("d")
print '%s %.2f' %("new damping ratio = ",drNew)
# e
# for a maximum overshoot of 25% , (F + Qo)/2*sqrt(K*J) = 0.4
Qo = (0.4*2.*math.sqrt(Kp*KaNew*Km*J)) - F ;
Ko = Qo/(KaNew*K) ; # output gain factor
print '%s' %("e")
print '%s %.2e' %("output gain factor = ",Ko)