import math
#initialisation of variables
V_s=230.0
V_m=math.sqrt(2)*V_s
a1=0
a2=45.0
#Calculations
print("for two single phase series semiconvertors")
V_0=V_m/math.pi*(2+math.cos(math.radians(a1))+math.cos(math.radians(a2)))
print("avg o/p voltage=%.2f V" %V_0)
V_or=V_s*math.sqrt((1/math.pi)*(4*math.pi-3*a2*math.pi/180+(3/2)*math.sin(math.radians(2*a2))))
print("rms value of o/p voltage=%.2f V" %V_or)
DF=(3+math.cos(math.radians(a2)))/(math.sqrt(2)*math.sqrt(5+3*math.cos(math.radians(a2))))
print("DF=%.2f" %DF)
PF=math.sqrt(2/math.pi)*(3+math.cos(math.radians(a2)))/math.sqrt(4*math.pi-3*a2*math.pi/180)
print("PF=%.2f" %PF)
HF=math.sqrt((math.pi*(math.pi-(3/4)*a2*math.pi/180)/(5+3*math.cos(math.radians(a2))))-1)
print("HF=%.2f" %HF)
print("for two single phase series full convertors")
a=45.0
V_0=2*V_m/math.pi*(1+math.cos(math.radians(a)))
print("avg o/p voltage=%.2f V" %V_0)
V_or=2*V_s*math.sqrt((1/math.pi)*(math.pi-a2*math.pi/180+(1/2)*math.sin(math.radians(2*a2))))
print("rms value of o/p voltage=%.2f V" %V_or)
DF=math.cos(math.radians(a2/2))
#Results
print("DF=%.2f" %DF)
PF=math.sqrt(2/(math.pi*(math.pi-a2*math.pi/180)))*(1+math.cos(math.radians(a2)))
print("PF=%.2f" %PF)
HF=math.sqrt((math.pi*(math.pi-a2*math.pi/180)/(4+4*math.cos(math.radians(a2))))-1)
print("HF=%.2f" %HF)