%pylab notebook
%precision %.4g

"""
Explanation: Excercises Electric Machinery Fundamentals
Chapter 4
Problem 4-28
End of explanation
"""


Sload  = 300e6 # [VA]
PF     =   0.85
f_drop =   3.0 # [Hz]
f_sys  =  60.0 # [Hz]

"""
Explanation: Description
A generating station for a power system consists of four 300-MVA, 15-kV, 0.85-PF-lagging synchronous
generators with identical speed droop characteristics operating in parallel. The governors on the
generators’ prime movers are adjusted to produce a 3-Hz drop from no load to full load. Three of these
generators are each supplying a steady 200 MW at a frequency of 60 Hz, while the fourth generator
(called the swing generator) handles all incremental load changes on the system while maintaining the
system's frequency at 60 Hz.
End of explanation
"""


Pfl = Sload * PF
Pfl/1e6

"""
Explanation: (a)
At a given instant, the total system loads are 650 MW at a frequency of 60 Hz. 

What are the no-load frequencies of each of the system’s generators?

(b)
If the system load rises to 725 MW and the generator’s governor set points do not change

What will the new system frequency be?

(c)

To what frequency must the no-load frequency of the swing generator be adjusted in order to restore the system frequency to 60 Hz?

(d)
If the system is operating at the conditions described in part (c)

What would happen if the swing generator were tripped off the line (disconnected from the power line)?

SOLUTION
(a)
The full-load power of these generators is:
End of explanation
"""


sp = Pfl / f_drop
print('sp = {:.0f} MW/Hz'.format(sp/1e6))

"""
Explanation: and the droop from no-load to full-load is 3 Hz. Therefore, the slope of the power-frequency curve for these four generators is:
End of explanation
"""


P1 = 200e6 # [W]
P2 = 200e6 # [W]
P3 = 200e6 # [W]
P4 =  50e6 # [W]
f_nl_1 = P1/sp + f_sys
f_nl_2 = P2/sp + f_sys
f_nl_3 = P3/sp + f_sys
f_nl_4 = P4/sp + f_sys
print('''
f_nl_1 = {:.2f} Hz
f_nl_2 = {:.2f} Hz
f_nl_3 = {:.2f} Hz
f_nl_4 = {:.2f} Hz
================='''.format(f_nl_1, f_nl_2, f_nl_3, f_nl_4))

"""
Explanation: If generators 1, 2, and 3 are supplying 200 MW each, then generator 4 must be supplying 50 MW. The
no-load frequency of the first three generators is:
$$P = s_{P}(f_\text{nl} - f_\text{sys})$$
End of explanation
"""


Pload = 725e6 # [W]
f_sys_b = (sp*f_nl_1 + sp*f_nl_2 + sp*f_nl_3 + sp*f_nl_4 - Pload) /
          (sp + sp + sp + sp)
print('''
f_sys = {:.2f} Hz
================'''.format(f_sys_b))

"""
Explanation: (b)
The setpoints of generators 1, 2, 3, and 4 do not change, so the new system frequency will be:
$$P_\text{load} = s_{P1}(f_\text{nl,1} - f_{sys}) + s_{P2}(f_\text{nl,2} - f_{sys}) + s_{P3}(f_\text{nl,3} - f_\text{sys}) + s_{P4}(f_\text{nl,4} - f_\text{sys})$$
End of explanation
"""


P4_c = Pload - 3*P1
P4_c/1e6

"""
Explanation: (c)
The governor setpoint of the swing generator must be increased until the system frequency rises
back to 60 Hz. At 60 Hz, the other three generators will be supplying 200 MW each, so at 60 Hz, the swing
generator must supply:
End of explanation
"""


f_nl4_c = P4_c/sp + f_sys
print('''
f_nl4_c = {:.2f} Hz
=================='''.format(f_nl4_c))

"""
Explanation: Therefore, the swing generator’s setpoint must be set to:
$$P_4 = s_{P4}(f_\text{nl4} - f_\text{sys})$$
End of explanation
"""


f_sys_d = (sp*f_nl_1 + sp*f_nl_2 + sp*f_nl_3 - Pload) / (sp + sp + sp)
print('''
f_sys_d = {:.2f} Hz and each generator will supply {:.1f} MW to the loads.
========================================================================
'''.format(f_sys_d, Pload/3/1e6))

"""
Explanation: (d)
If the swing generator trips off the line, the other three generators would have to supply all 725 MW
of the load. Therefore, the system frequency will become:
$$P_\text{load} = s_{P1}(f_\text{nl,1} - f_\text{sys}) + s_{P2}(f_\text{nl,2} - f_\text{sys}) + s_{P3}(f_\text{nl,3} - f_\text{sys})$$
End of explanation
"""


