#Determine the turns ratio of the transformer
#given
import math
Rl=8.;#ohm
Rl_=5.*10.**3.;#ohm
TR=math.sqrt(Rl_/Rl); #Turns ratio
print '%s %.f %s' %("Turns Ratio =",TR,": 1");
#Determine the output impedance of the transistor
#given
TR=16./1.; #turn ratio
Rl=4.;#ohm #loudspeaker impedance
ro=(TR**2.)*Rl;
print '%s %.f %s' %("The output impedance of the transistor =",ro,"ohm");
#Determine the efficiency of a single ended transformer
#given
Vceq=10.;#V #supply voltage
#At Vp=10V
Vp=10.;#V
Vce_max1=Vceq+Vp;
Vce_min1=Vceq-Vp;
n1=50.*((Vce_max1-Vce_min1)/(Vce_max1+Vce_min1))**2.;
print '%s %.f %s' %("Efficiency (At Vp = 10V)=",n1,"percent\n");
#At Vp=5V
Vp=5.;#V
Vce_max2=Vceq+Vp;
Vce_min2=Vceq-Vp;
n2=50.*((Vce_max2-Vce_min2)/(Vce_max2+Vce_min2))**2.;
print '%s %.1f %s' %("Efficiency (At Vp = 5V)=",n2,"percent\n");
#At Vp=1V
Vp=1.;#V
Vce_max3=Vceq+Vp;
Vce_min3=Vceq-Vp;
n3=50.*((Vce_max3-Vce_min3)/(Vce_max3+Vce_min3))**2.;
print '%s %.1f %s' %("Efficiency (At Vp = 1V)=",n3,"percent\n");
#Determine input and output power and efficiency
#given
import math
Vcc=20.;#V#supply voltage
Rl=4.;#ohm
Vp=15.;#V
Ip=Vp/Rl;
Idc=Ip/math.pi;
Pi=Vcc*Idc;
Po=((Vp/2.)**2.)/Rl;
n=100.*Po/Pi;
print '%s %.1f %s' %("Input power =",Pi,"W\n");
print '%s %.2f %s' %("Output power =",Po,"W\n");
print '%s %.2f %s' %("Efficiency =",n,"percent\n");
#Calculate the percentage increase in output power
#given
D=0.2;#harmonic distortion
P=(1.+D**2.);#Total power increase
#percent increase= (Pi*(1+D**2)-Pi)*100/Pi;
#taking out and cancelling Pi
PI=(P-1.)*100.;
print '%s %.f %s' %("The percentage increase in output power=",PI,"percent");
#Calculate harmonic distortion and percentage increase in output voltage due to this
#given
import math
I1=60.;#A
I2=6.;#A
I3=1.2;#A
I4=0.6;#A
D2=I2/I1;
D3=I3/I1;
D4=I4/I1;
print '%s %.f %s %s %.f %s %s %.f %s' %("The Harmonic distortion of each component \nD2=",D2*100,"percent\n","\nD3=",D3*100,"percent\n","\nD4=",D4*100,"percent\n");
D=math.sqrt((D2)**2.+(D3)**2.+(D4)**2.);
print '%s %.f %s' %("The Total Harmonic distortion =",D*100,"percent\n");
P=(1.+D**2.);#Total power increase
#percent increase= (Pi*(1+D**2)-Pi)*100/Pi;
#taking out and cancelling Pi
PI=(P-1.)*100.;
print '%s %.f %s' %("The percentage increase in output power =",PI,"percent");
#Calculate harmonic distortion and percentage increase in output voltage due to this
#given
import math
I1=60.;#A
I2=6.;#A
I3=1.2;#A
I4=0.6;#A
D2=I2/I1;
D3=I3/I1;
D4=I4/I1;
print '%s %.f %s %s %.f %s %s %.f %s' %("The Harmonic distortion of each component \nD2=",D2*100,"percent\n","\nD3=",D3*100,"percent\n","\nD4=",D4*100,"percent\n");
D=math.sqrt((D2)**2.+(D3)**2.+(D4)**2.);
print '%s %.f %s' %("The Total Harmonic distortion =",D*100,"percent\n");
P=(1.+D**2.);#Total power increase
#percent increase= (Pi*(1+D**2)-Pi)*100/Pi;
#taking out and cancelling Pi
PI=(P-1.)*100.;
print '%s %.f %s' %("The percentage increase in output power =",PI,"percent");