<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 1
Problem 1-19
Step1:  Description
Figure P1-14 shows a simple single-phase ac power system with three loads. The voltage source is
$\vec{V} = 240\,V\angle 0^\circ$, impedances of these three loads are
Step2:  Answer the following questions about this power system.
(a)
Assume that the switch shown in the figure is initially open, and calculate the current I , the power factor, and the real, reactive, and apparent power being supplied by the source.
(b)
How much real, reactive, and apparent power is being consumed by each load with the switch open?
(c)
Assume that the switch shown in the figure is now closed, and calculate the current I , the power factor, and the real, reactive, and apparent power being supplied by the source.
(d)
How much real, reactive, and apparent power is being consumed by each load with the switch closed?
(e)
What happened to the current flowing from the source when the switch closed? Why?
SOLUTION
(a)
With the switch open, only loads 1 and 2 are connected to the source. The current $\vec{I}_1$ in Load 1 and the current $\vec{I}_2$ in Load 2 are
Step3:  Therefore the total current from the source is $\vec{I} = \vec{I}_1 + \vec{I}_2$
Step4:  The power factor supplied by the source is
Step5:  lagging (because current laggs behind voltage). 
Note that the angle $\theta$ used in the power factor and power calculations is the impedance angle, which is the negative of the current angle as long as voltage is at $0^\circ$.
The real, reactive, and apparent power supplied by the source are
$$S = VI^* \quad P = VI\cos\theta = real(S) \quad Q = VI\sin\theta = imag(S)$$
Step6:  Let's pretty-print that
Step7:  (b)
The real, reactive, and apparent power consumed by Load 1 and by Load 2 respectively are
Step8:  Let's pretty-print that
Step9:  As expected, the real and reactive power supplied by the source are equal to the sum of the
real and reactive powers consumed by the loads.
(c)
With the switch closed, all three loads are connected to the source. The current in Loads 1 and 2 is the same as before. The current $\vec{I}_3$  in Load 3 is
Step10:  Therefore the total current from the source is $\vec{I} = \vec{I}_1 + \vec{I}_2 + \vec{I}_3$
Step11:  The power factor supplied by the source is
Step12:  lagging (because current laggs behind voltage). 
The real, reactive, and apparent power supplied by the source are
$$S = VI^* \quad P = VI\cos\theta = real(S) \quad Q = VI\sin\theta = imag(S)$$
Step13:  Let's pretty-print that
Step14:  (d)
The real, reactive, and apparent power consumed by Load 1, Load 2 and by Load 3 respectively are
<ASSISTANT_TASK:>
Python Code:
%pylab notebook
%precision %.4g
Explanation: Excercises Electric Machinery Fundamentals
Chapter 1
Problem 1-19
End of explanation
V  = 240  # [V]
Z1 = 10.0 * exp(1j* 30/180*pi)  
Z2 = 10.0 * exp(1j* 45/180*pi)  
Z3 = 10.0 * exp(1j*-90/180*pi)  
Explanation: Description
Figure P1-14 shows a simple single-phase ac power system with three loads. The voltage source is
$\vec{V} = 240\,V\angle 0^\circ$, impedances of these three loads are:
$$\vec{Z}_1 =  10\,\Omega\angle 30^\circ \quad \vec{Z}_2 =  10\,\Omega\angle 45^\circ \quad \vec{Z}_3 =  10\,\Omega\angle -90^\circ $$
<img src="figs/FigC_P1-14.jpg" width="80%">
End of explanation
I1 = V/Z1
I2 = V/Z2
I1_angle = arctan(I1.imag/I1.real)
I2_angle = arctan(I2.imag/I2.real)
print('''I1 = {:.1f} A ∠{:.1f}°
I2 = {:.1f} A ∠{:.1f}°'''.format(
        abs(I1), I1_angle/pi*180,
        abs(I2), I2_angle/pi*180))
Explanation: Answer the following questions about this power system.
(a)
Assume that the switch shown in the figure is initially open, and calculate the current I , the power factor, and the real, reactive, and apparent power being supplied by the source.
(b)
How much real, reactive, and apparent power is being consumed by each load with the switch open?
(c)
Assume that the switch shown in the figure is now closed, and calculate the current I , the power factor, and the real, reactive, and apparent power being supplied by the source.
(d)
How much real, reactive, and apparent power is being consumed by each load with the switch closed?
(e)
What happened to the current flowing from the source when the switch closed? Why?
SOLUTION
(a)
With the switch open, only loads 1 and 2 are connected to the source. The current $\vec{I}_1$ in Load 1 and the current $\vec{I}_2$ in Load 2 are:
End of explanation
I = I1 + I2
I_angle = arctan(I.imag/I.real)
print('I = {:.1f} A ∠{:.1f}°'.format(
        abs(I), I_angle/pi*180))
print('==================')           
Explanation: Therefore the total current from the source is $\vec{I} = \vec{I}_1 + \vec{I}_2$:
End of explanation
PF = cos(-I_angle)
PF
Explanation: The power factor supplied by the source is:
End of explanation
So = V*conj(I)    # I use index "o" for open switch
So
Explanation: lagging (because current laggs behind voltage). 
Note that the angle $\theta$ used in the power factor and power calculations is the impedance angle, which is the negative of the current angle as long as voltage is at $0^\circ$.
The real, reactive, and apparent power supplied by the source are
$$S = VI^* \quad P = VI\cos\theta = real(S) \quad Q = VI\sin\theta = imag(S)$$
End of explanation
print('''
So = {:>7.1f} VA
Po = {:>7.1f} W
Qo = {:>7.1f} var
================'''.format(abs(So), So.real, So.imag))
Explanation: Let's pretty-print that:
End of explanation
S1o = V*conj(I1)
S1o
S2o = V*conj(I2)
S2o
Explanation: (b)
The real, reactive, and apparent power consumed by Load 1 and by Load 2 respectively are:
End of explanation
print('''
S1o = {:>6.1f} VA
P1o = {:>6.1f} W
Q1o = {:>6.1f} var
----------------
S2o = {:>6.1f} VA
P2o = {:>6.1f} W
Q2o = {:>6.1f} var
================'''.format(abs(S1o), S1o.real, S1o.imag,
                           abs(S2o), S2o.real, S2o.imag))
Explanation: Let's pretty-print that:
End of explanation
I3 = V/Z3
I3_angle = arctan(I3.imag/I3.real)
print('I3 = {:.1f} A ∠{:.1f}°'.format(abs(I3), I3_angle/pi*180))           
Explanation: As expected, the real and reactive power supplied by the source are equal to the sum of the
real and reactive powers consumed by the loads.
(c)
With the switch closed, all three loads are connected to the source. The current in Loads 1 and 2 is the same as before. The current $\vec{I}_3$  in Load 3 is:
End of explanation
I = I1 + I2 + I3
I_angle = arctan(I.imag/I.real)
print('I = {:.1f} A ∠{:.1f}°'.format(abs(I), I_angle/pi*180))
print('=================')           
Explanation: Therefore the total current from the source is $\vec{I} = \vec{I}_1 + \vec{I}_2 + \vec{I}_3$:
End of explanation
PF = cos(-I_angle)
PF
Explanation: The power factor supplied by the source is:
End of explanation
Sc = V*conj(I)    # I use index "c" for closed switch
Sc
Explanation: lagging (because current laggs behind voltage). 
The real, reactive, and apparent power supplied by the source are
$$S = VI^* \quad P = VI\cos\theta = real(S) \quad Q = VI\sin\theta = imag(S)$$
End of explanation
print('''
Sc = {:.1f} VA
Pc = {:.1f} W
Qc = {:.1f} var
==============='''.format(abs(Sc), Sc.real, Sc.imag))
Explanation: Let's pretty-print that:
End of explanation
S1c = V*conj(I1)
S1c
S2c = V*conj(I2)
S2c
S3c = V*conj(I3)
S3c
print('''
S1c = {:>7.1f} VA
P1c = {:>7.1f} W
Q1c = {:>7.1f} var
-----------------
S2c = {:>7.1f} VA
P2c = {:>7.1f} W
Q2c = {:>7.1f} var
-----------------
S3c = {:>7.1f} VA
P3c = {:>7.1f} W
Q3c = {:>7.1f} var
================='''.format(abs(S1c), S1c.real, S1c.imag,
                            abs(S2c), S2c.real, S2c.imag,
                            abs(S3c), S3c.real, S3c.imag))
Explanation: (d)
The real, reactive, and apparent power consumed by Load 1, Load 2 and by Load 3 respectively are:
End of explanation
<END_TASK>