MVA_base = 10.0 #Three-phase base MVA
kV_base = 13.8 #Line-line base kV
P = 7.0 #Power delivered(MW)
PF = 0.8 #Power factor lagging
Z = 5.7 #Impedance(ohm)
import math
I_base = (MVA_base) * (10**3)/((3**(0.5)) * kV_base) #Base current(A)
I_actual = P * (10**3)/((3**(0.5)) * kV_base*PF) #Actual current delivered by machine(A)
I_pu = I_actual/I_base #p.u current(p.u)
Z_pu = Z * (MVA_base/( (kV_base)**2 )) #p.u impedance(p.u)
P_act_pu = P/MVA_base #p.u active power(p.u)
x = math.acos(PF)
y = math.sin(x)
P_react = (P * y)/PF #Actual reactive power(MVAR)
P_react_pu = P_react/MVA_base #Actual p.u reactive power(p.u)
print('p.u current = %.3f p.u' %I_pu)
print('p.u impedance = %.1f p.u' %Z_pu)
print('p.u active power = %.1f p.u' %P_act_pu)
print('p.u reactive power = %.3f p.u' %P_react_pu)
MVA_base = 5.0 #Base MVA on both sides
hv_base = 11.0 #Line to line base voltages in kV on h.v side
lv_base = 0.4 #Line to line base voltages in kV on l.v side
Z = 5.0/100 #Impedance of 5%
Z_base_hv = (hv_base)**2/MVA_base #Base impedance on h.v side(ohm)
Z_base_lv = (lv_base)**2/MVA_base #Base impedance on l.v side(ohm)
Z_act_hv = Z * Z_base_hv #Actual impedance viewed from h.v side(ohm)
Z_act_lv = Z * Z_base_lv #Actual impedance viewed from l.v side(ohm)
print('Base impedance on h.v side = %.1f ohm' %Z_base_hv)
print('Base impedance on l.v side = %.3f ohm' %Z_base_lv)
print('Actual impedance viewed from h.v side = %.2f ohm' %Z_act_hv)
print('Actual impedance viewed from l.v side = %.4f ohm' %Z_act_lv)