<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Excercises Electric Machinery Fundamentals
Chapter 2
Problem 2-9
Step1:  Description
A 5000-kVA 230/13.8-kV single-phase power transformer has a per-unit resistance of 1 percent and a per-unit reactance of 5 percent (data taken from the transformer’s nameplate).
Step2:  The open-circuit test performed on the low-voltage side of the transformer yielded the following data
Step3:  (a)
Find the equivalent circuit referred to the low-voltage side of this transformer.
(b)
If the voltage on the secondary side is 13.8 kV and the power supplied is 4000 kW at 0.8 PF lagging.
Find the voltage regulation of the transformer. 
Find its efficiency.
SOLUTION
(a)
The open-circuit test was performed on the low-voltage side of the transformer, so it can be used to directly find the components of the excitation branch relative to the low-voltage side.
$$|Y_{EX}| = |G_{C} - jB_{M}| = \frac{I_{OC}}{V_{OC}}$$
Step4:  $\theta = \arccos\frac{P_{OC}}{V_{OC}I_{OC}}$
Step5:  $$Y_{EX} = G_C - jB_M$$
Step6:  The base impedance of this transformer referred to the secondary side is
Step7:  Thus
Step8:  The resulting equivalent circuit is shown below
Step9:  (b)
If the load on the secondary side of the transformer is 4000 kW at 0.8 PF lagging and the secondary voltage is 13.8 kV, the secondary current is
Step10:  The voltage on the primary side of the transformer (referred to the secondary side) is
Step11:  There is a voltage drop under these load conditions. 
Therefore the voltage regulation of the transformer is
Step12:  The transformer copper losses and core losses are
Step13:  Therefore the efficiency of this transformer at these conditions is
<ASSISTANT_TASK:>
Python Code:
%pylab notebook
Explanation: Excercises Electric Machinery Fundamentals
Chapter 2
Problem 2-9
End of explanation
Sbase = 5000e3  # [VA]
Vp0 = 230e3     # [V]
Vs0 = 13.8e3    # [V]
Req_pu = 0.01
Xeq_pu = 0.05
Explanation: Description
A 5000-kVA 230/13.8-kV single-phase power transformer has a per-unit resistance of 1 percent and a per-unit reactance of 5 percent (data taken from the transformer’s nameplate).
End of explanation
Voc = 13.8e3  # [V]
Ioc = 21.1    # [A]
Poc = 90.8e3  # [W]
Explanation: The open-circuit test performed on the low-voltage side of the transformer yielded the following data:
$$V_{OC} = 13.8kV \qquad I_{OC} = 21.1A \qquad P_{OC} = 90.8kW$$
End of explanation
yex = Ioc / Voc
print('yex = {:.6f}'.format(yex))
Explanation: (a)
Find the equivalent circuit referred to the low-voltage side of this transformer.
(b)
If the voltage on the secondary side is 13.8 kV and the power supplied is 4000 kW at 0.8 PF lagging.
Find the voltage regulation of the transformer. 
Find its efficiency.
SOLUTION
(a)
The open-circuit test was performed on the low-voltage side of the transformer, so it can be used to directly find the components of the excitation branch relative to the low-voltage side.
$$|Y_{EX}| = |G_{C} - jB_{M}| = \frac{I_{OC}}{V_{OC}}$$
End of explanation
theta = arccos(Poc/(Voc*Ioc))
print('theta = {:.2f}°'.format(theta/pi*180))  # print the angle in degrees
Yex = yex * (cos(theta) - sin(theta)*1j)
print('Yex = {:.7f} S'.format(Yex))
Explanation: $\theta = \arccos\frac{P_{OC}}{V_{OC}I_{OC}}$
End of explanation
Gc = Yex.real
Bm = -Yex.imag
Rc = 1/Gc
Xm = 1/Bm
print('Rc = {:4.0f} Ω'.format(Rc))
print('Xm = {:4.0f} Ω'.format(Xm))
Explanation: $$Y_{EX} = G_C - jB_M$$
End of explanation
Vbase = Vs0
Zbase = Vbase**2 / Sbase
print('Zbase = {:.2f} Ω'.format(Zbase))
Explanation: The base impedance of this transformer referred to the secondary side is:
$$Z_\text{base} = \frac{V^2_\text{base}}{S_\text{base}}$$
End of explanation
Req = Req_pu * Zbase
Xeq = Xeq_pu * Zbase
print('Req = {:4.2f} Ω'.format(Req))
print('Xeq = {:4.2f} Ω'.format(Xeq))
Explanation: Thus:
End of explanation
print('''
Req,s = {:.2f} Ω   Xeq,s = {:.1f} Ω 
Rc,s  = {:.0f} Ω    Xm,s = {:.0f} Ω 
==============================
'''.format(Req, Xeq, Rc, Xm))
Explanation: The resulting equivalent circuit is shown below:
<img src="figs/Problem_2-09.jpg" width="50%">
End of explanation
Pload_b = 4000e3 # [W]
VS_b    = 13.8e3 # [V]
PF      = 0.8
Is_b = Pload_b / (abs(VS_b) * PF)
print('Is_b = {:.1f} A'.format(Is_b))
Is_b_angle = -arccos(PF)    # [rad]
IS_b = Is_b * (cos(Is_b_angle) + sin(Is_b_angle)*1j)
print('IS_b = {:.1f} A ∠{:.2f}°'.format(
            abs(IS_b), Is_b_angle/pi*180))
Explanation: (b)
If the load on the secondary side of the transformer is 4000 kW at 0.8 PF lagging and the secondary voltage is 13.8 kV, the secondary current is:
$$I_S = \frac{P_{LOAD}}{V_SPF}$$
End of explanation
Zeq = Req + Xeq*1j
V_P = VS_b + IS_b*Zeq
V_P_angle = arctan(V_P.imag/V_P.real)
print('V_P = {:.0f} V ∠{:.1f}°'.format(
            abs(V_P), V_P_angle/pi*180))
Explanation: The voltage on the primary side of the transformer (referred to the secondary side) is:
$$\vec{V}'P = \vec{V}_S + \vec{I}_SZ{EQ}$$
End of explanation
VR = (abs(V_P)-abs(VS_b)) / abs(VS_b) *100
print('VR = {:.2f} %'.format(VR))
print('===========')
Explanation: There is a voltage drop under these load conditions. 
Therefore the voltage regulation of the transformer is:
$$VR = \frac{V'_P-V_S}{V_S} \cdot 100\%$$
End of explanation
Pcu = abs(IS_b)**2 * Req
Pcore = abs(V_P)**2 / Rc
print('Pcu   = {:.1f} kW'.format(Pcu/1000))
print('Pcore = {:.1f} kW'.format(Pcore/1000))
Explanation: The transformer copper losses and core losses are:
$$P_{CU} = I^2_S R_{EQ,S}$$
$$P_{core} = \frac{(V'_P)^2}{R_C}$$
End of explanation
Pout = Pload_b
eta = Pout / (Pout + Pcu +Pcore) * 100
print('η = {:.1f} %'.format(eta))
print('==========')
Explanation: Therefore the efficiency of this transformer at these conditions is:
$$\eta = \frac{P_{OUT}}{P_{OUT}+P_{CU}+P_{core}} \cdot 100\%$$
End of explanation
<END_TASK>