<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 4
Problem 4-2
Step1:  Description
Given a 13.8-kV, 50-MVA, 0.9-power-factor-lagging, 60-Hz, four-pole, Y-connected synchronous machine with
Step2:  (a)
How much field current is required to make the terminal voltage $V_T$ (or line voltage $V_L$ ) equal to 13.8 kV when the generator is running at no load?
(b)
What is the internal generated voltage $E_A$ of this machine at rated conditions?
(c)
What is the phase voltage $V_\phi$ of this generator at rated conditions?
(d)
How much field current is required to make the terminal voltage $V_T$ equal to 13.8 kV when the generator is running at rated conditions?
(e)
Suppose that this generator is running at rated conditions, and then the load is removed without changing the field current. 
What would the terminal voltage of the generator be?
(f)
How much steady-state power and torque must the generator’s prime mover be capable of supplying to handle the rated conditions?
(g)
Construct a capability curve for this generator.
SOLUTION
(a)
If the no-load terminal voltage is 13.8 kV, the required field current can be read directly from the open-circuit characteristic. It is $\underline{\underline{I_F = 3.50\,A}}$.
(b)
This generator is Y-connected, so $I_L = I_A$ . At rated conditions, the line and phase current in this generator is
Step3:  The phase voltage of this machine is
Step4:  The internal generated voltage of the machine is
Step5:  (c)
The phase voltage of the machine at rated conditions is
Step6:  (d)
The equivalent open-circuit terminal voltage corresponding to an $E_A$ of the value calculated in (b) is
Step7:  From the OCC, the required field current is $\underline{\underline{I_F = 10\,A}}$.
(e)
If the load is removed without changing the field current then $V_\phi = E_A$
Step8:  The corresponding terminal voltage would be $\underline{\underline{V_T = 20\,kV}}$.
(f)
The input power to this generator is equal to the output power plus losses. The rated output power is
Step9:  $$P_{CU} = 3I^2_AR_A$$
Step10:  Therefore the prime mover must be capable of supplying $P_{in}$. Since the generator is a four-pole 60 Hz machine, to must be turning at 1800 r/min. The required torque is
Step11:  (e)
The rotor current limit of the capability curve would be drawn from an origin of
Step12:  The radius of the rotor current limit is
Step13:  The stator current limit is a circle at the origin of radius
Step14:  Get points for stator current limit
Step15:  Get points for rotor current limit
Step16:  Plot the capability diagram
<ASSISTANT_TASK:>
Python Code:
%pylab notebook
%precision 0
Explanation: Excercises Electric Machinery Fundamentals
Chapter 4
Problem 4-2
End of explanation
Vl = 13.8e3    # [V] 
PF = 0.9
Xs = 2.5       # [Ohm]
Ra = 0.2       # [Ohm]
P      =  50e6 # [W]
Pf_w   = 1.0e6 # [W]
Pcore  = 1.5e6 # [W]
Pstray =     0 # [W]
n_m = 1800     # [r/min]
Explanation: Description
Given a 13.8-kV, 50-MVA, 0.9-power-factor-lagging, 60-Hz, four-pole, Y-connected synchronous machine with:
a synchronous reactance of $2.5\,\Omega$ 
an armature resistance of $0.2\,\Omega$.
at 60 Hz, its friction and windage losses are 1 MW
its core losses are 1.5 MW. 
The field circuit has a dc voltage of 120 V,
the maximum $I_F$ is 10 A. The current of the field circuit is adjustable over the range from 0 to 10 A. 
The OCC of this generator is shown in Figure P4-1 below
<img src="figs/FigC_P4-1.jpg" width="70%">
End of explanation
ia = P / (sqrt(3) * Vl)
Ia_angle = -arccos(PF)
Ia = ia * (cos(Ia_angle) + sin(Ia_angle)*1j)
print('Ia = {:.0f} A ∠{:.1f}°'.format(abs(Ia), Ia_angle/pi *180))
Explanation: (a)
How much field current is required to make the terminal voltage $V_T$ (or line voltage $V_L$ ) equal to 13.8 kV when the generator is running at no load?
(b)
What is the internal generated voltage $E_A$ of this machine at rated conditions?
(c)
What is the phase voltage $V_\phi$ of this generator at rated conditions?
(d)
How much field current is required to make the terminal voltage $V_T$ equal to 13.8 kV when the generator is running at rated conditions?
(e)
Suppose that this generator is running at rated conditions, and then the load is removed without changing the field current. 
What would the terminal voltage of the generator be?
(f)
How much steady-state power and torque must the generator’s prime mover be capable of supplying to handle the rated conditions?
(g)
Construct a capability curve for this generator.
SOLUTION
(a)
If the no-load terminal voltage is 13.8 kV, the required field current can be read directly from the open-circuit characteristic. It is $\underline{\underline{I_F = 3.50\,A}}$.
(b)
This generator is Y-connected, so $I_L = I_A$ . At rated conditions, the line and phase current in this generator is:
$$I_A = I_L = \frac{P}{\sqrt{3}V_L}$$
End of explanation
V_phase = Vl / sqrt(3)
print('V_phase = {:.0f} V'.format(V_phase))
Explanation: The phase voltage of this machine is:
$$V_\phi = V_T / \sqrt{3}$$
End of explanation
Ea = V_phase + Ra*Ia + Xs*1j*Ia
Ea_angle = arctan(Ea.imag/Ea.real)
print('''
Ea = {:.0f} V ∠{:.1f}°
=================='''.format(abs(Ea), Ea_angle/pi*180))
Explanation: The internal generated voltage of the machine is:
$$\vec{E}A = \vec{V}\phi + R_A\vec{I}_A + jX_S\vec{I}_A$$
End of explanation
print('''
V_phase = {:.0f} V
================'''.format(V_phase))
Explanation: (c)
The phase voltage of the machine at rated conditions is:
End of explanation
Vt_oc = sqrt(3) * abs(Ea)
print('Vt_oc = {:.0f} kV'.format(Vt_oc/1000))
Explanation: (d)
The equivalent open-circuit terminal voltage corresponding to an $E_A$ of the value calculated in (b) is:
End of explanation
abs(Ea)
Explanation: From the OCC, the required field current is $\underline{\underline{I_F = 10\,A}}$.
(e)
If the load is removed without changing the field current then $V_\phi = E_A$:
End of explanation
Pout = P*PF
print('Pout = {:.0f} MW'.format(Pout/1e6))
Explanation: The corresponding terminal voltage would be $\underline{\underline{V_T = 20\,kV}}$.
(f)
The input power to this generator is equal to the output power plus losses. The rated output power is:
End of explanation
Pcu = 3 * abs(Ia)**2 * Ra
print('Pcu = {:.1f} MW'.format(Pcu/1e6))
Pin = Pout +Pcu + Pf_w + Pcore + Pstray
print('Pin = {:.1f} MW'.format(Pin/1e6))
Explanation: $$P_{CU} = 3I^2_AR_A$$
End of explanation
w_m = n_m * (2*pi/60.0)
tau_app = Pin / w_m
print('''
tau_app = {:.0f} Nm
==================='''.format(tau_app))
Explanation: Therefore the prime mover must be capable of supplying $P_{in}$. Since the generator is a four-pole 60 Hz machine, to must be turning at 1800 r/min. The required torque is:
$$\tau_{app} = \frac{P_{in}}{\omega_m}$$
End of explanation
Q = - (3 * V_phase**2) / Xs
print('Q = {:.2f} Mvar'.format(Q/1e6))
Explanation: (e)
The rotor current limit of the capability curve would be drawn from an origin of:
$$Q = -\frac{3V^2_\phi}{X_S}$$
End of explanation
De = (3 * V_phase * abs(Ea)) / Xs
print('De = {:.0f} Mvar'.format(De/1e6))
Explanation: The radius of the rotor current limit is:
$$D_E = \frac{3V_\phi E_A}{X_S}$$
End of explanation
S = 3 * V_phase * abs(Ia)
print('S = {:.0f} Mvar'.format(S/1e6))
Explanation: The stator current limit is a circle at the origin of radius:
$$S = 3V_\phi I_A$$
End of explanation
theta = arange(-95,95) # angle in degrees
rad = theta * pi/180   # angle in radians
s_curve = S * ( cos(rad) + sin(rad)*1j)
Explanation: Get points for stator current limit:
End of explanation
orig = Q*1j
theta = arange(65,115)  # angle in degrees
rad = theta * pi / 180  # angle in radians
r_curve = orig + De * ( cos(rad) + sin(rad)*1j )
Explanation: Get points for rotor current limit:
End of explanation
fig= figure()
ax=fig.add_subplot(1, 1, 1)
ax.plot(real(s_curve/1e6),imag(s_curve/1e6),'b')
ax.plot(real(r_curve/1e6),imag(r_curve/1e6),'r--')
ax.set_title('Synchronous Generator Capability Diagram')
ax.set_xlabel('Power (MW)')
ax.set_ylabel('Reactive Power (Mvar)')
ax.set_aspect('equal', 'datalim')
ax.legend(('stator current limit', 'rotor current limit'), loc=3);
ax.grid()
Explanation: Plot the capability diagram:
End of explanation
<END_TASK>