I am working on the file "Chapman/Ch4-Problem_4-29.ipynb".
The first task is:
Plot the armature current versus Ea:
Can you write Python code for it?

rc('text', usetex=True)   # enable LaTeX commands for plot
title(r'Armature current versus $E_A$')
xlabel(r'$E_A$ [kV]')
ylabel(r'$I_A$ [A]')
plot(abs(Ea_)/1000,abs(Ia_),  linewidth = 2)
grid()


I am working on the file "Chapman/Ch4-Problem_4-29.ipynb".
The first task is:
Therefore, the internal generated voltage is:
$$\vec{E}A = \vec{V}\phi + R_A\vec{I}_A + jX_S\vec{I}_A$$
Can you write Python code for it?

EA = Vphi_base + Ra*Ia + Xs*1j *Ia
EA_angle = arctan(EA.imag/EA.real)
print('''
EA = {:.0f} V ∠{:.2f}°
===================='''.format(abs(EA), EA_angle/pi*180))


I am working on the file "Chapman/Ch4-Problem_4-29.ipynb".
The first task is:
Therefore, the new armature current is:
$$\vec{I}A = \frac{\vec{E}{A2} - \vec{V}_\phi}{jX_S}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch4-Problem_4-29.ipynb".
The first task is:
Therefore, the new armature current is:
Can you write Python code for it?


I am working on the file "Chapman/Ch4-Problem_4-29.ipynb".
The first task is:
With a 20% decrease,
Can you write Python code for it?

Ea1 = abs(EA)
Ea5 = Ea1 * 0.80
print('Ea1 = {:.0f} V    Ea5 = {:.0f} V'.format(Ea1, Ea5))

delta1 = EA_angle
delta5 = arcsin(Ea1/Ea5 * sin(delta1))
print('delta5 = {:.1f}°'.format(delta5/pi*180))
EA5 = Ea5 * exp(1j*delta5)


I am working on the file "Chapman/Ch4-Problem_4-29.ipynb".
The first task is:
With a 25% decrease,
Can you write Python code for it?

Ea1 = abs(EA)
Ea6 = Ea1 * 0.75
print('Ea1 = {:.0f} V    Ea6 = {:.0f} V'.format(Ea1, Ea6))

delta1 = EA_angle
delta6 = arcsin(Ea1/Ea6 * sin(delta1))
print('delta6 = {:.1f}°'.format(delta6/pi*180))
EA6 = Ea6 * exp(1j*delta6)


I am working on the file "Chapman/Ch5-Problem_5-01.ipynb".
The first task is:
$$\delta_2 = \arcsin\left(\frac{E_{A1}}{E_{A2}}\sin{\delta_1}\right)$$
Can you write Python code for it?

delta_1 = EA_angle
delta_2 = arcsin(abs(EA) / Ea_2 * sin(delta_1))
delta_2/pi *180 # [degrees]


I am working on the file "Chapman/Ch5-Problem_5-01.ipynb".
The first task is:
(c)
The induced torque is:
$$\tau_\text{ind} = \frac{P_\text{out}}{\omega_m}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch5-Problem_5-01.ipynb".
The first task is:
Calculate $I_A$
Can you write Python code for it?


I am working on the file "Chapman/Ch5-Problem_5-01.ipynb".
The first task is:
Calculate $\delta_2$
Can you write Python code for it?

delta_plot = arcsin(abs(EA) / Ea_plot * sin(delta_1))


I am working on the file "Chapman/Ch5-Problem_5-01.ipynb".
The first task is:
Calculate the phasor $E_A$
Can you write Python code for it?

EA_plot = Ea_plot * (cos(delta_plot)+sin(delta_plot)*1j)


I am working on the file "Chapman/Ch5-Problem_5-01.ipynb".
The first task is:
Description
A 480-V, 60 Hz, 400-hp 0.8-PF-leading eight-pole $\Delta$-connected synchronous motor has a synchronous
reactance of $0.6\,\Omega$ and negligible armature resistance. Ignore its friction, windage, and core losses for the
purposes of this problem. Assume that $|\vec{E}_A|$ is directly proportional to the field current $I_F$ (in other
words, assume that the motor operates in the linear part of the magnetization curve), and that $|\vec{E}_A| = 480\,V$ when $I_F = 4\,A$.
Can you write Python code for it?

Vt   = 480         # [V]
PF   =   0.8
fse  =  60         # [Hz]
p    =   8
Pout = 400 * 746   # [W] using the official "electrical horsepower" conversion
Xs   =   0.6       # [Ohm]


I am working on the file "Chapman/Ch5-Problem_5-01.ipynb".
The first task is:
Plot the v-curve
Can you write Python code for it?

title(r'Armature current versus $E_A$')
xlabel(r'$E_A$ [kV]')
ylabel(r'$I_A$ [A]')
plot(abs(EA_plot)/1000,abs(Ia_plot),  linewidth = 2)
grid()


I am working on the file "Chapman/Ch5-Problem_5-01.ipynb".
The first task is:
The angle of the current is:
Can you write Python code for it?

Ia_angle = -arccos(PF)
Ia_angle /pi *180 # [degrees]

Ia = ia * (cos(Ia_angle) + sin(Ia_angle)*1j)
print('Ia = {:.0f} A ∠{:.2f}°'.format(abs(Ia), Ia_angle / pi *180))


I am working on the file "Chapman/Ch5-Problem_5-01.ipynb".
The first task is:
The current operating torque is about
Can you write Python code for it?


I am working on the file "Chapman/Ch5-Problem_5-01.ipynb".
The first task is:
The internal generated voltage $\vec{E}A$ is:
$$\vec{E}_A = \vec{V}\phi - jX_S\vec{I}_A$$
Can you write Python code for it?

EA = Vt - Xs * 1j * Ia
EA_angle = arctan(EA.imag/EA.real)
print('''
EA = {:.0f} V ∠{:.1f}°
=================='''.format(abs(EA), EA_angle/pi*180))


I am working on the file "Chapman/Ch5-Problem_5-02.ipynb".
The first task is:
(a)

What are the magnitudes and angles of $\vec{E}_A$ and $\vec{I}_A$ , and $I_F$?

(b)
Suppose the load is removed from the motor.

What are the magnitudes and angles of $\vec{E}_A$ and $\vec{I}_A$ now?

SOLUTION
(a)
The line current flow at rated conditions is:
$$I_L = \frac{P}{\sqrt{3}V_TPF}$$
Can you write Python code for it?

Pin = Pout
il = Pin / (sqrt(3) * Vt * PF)
il # [A]


I am working on the file "Chapman/Ch5-Problem_5-02.ipynb".
The first task is:
(b)
When the load is removed from the motor the magnitude of $|\vec{E}_A|$ remains unchanged but the torque
angle goes to $\delta = 0°$ . The resulting armature current is:
$$\vec{I}A = \frac{\vec{V}\phi - \vec{E}_A}{jX_S}$$
Can you write Python code for it?

delta_b = 0*pi/180 # [rad]
EA_b = abs(EA) *(cos(delta_b) + sin(delta_b)*1j)
EA_b_angle = arctan(EA_b.imag/EA_b.real)

Ia_b = (Vt - EA_b) / (Xs*1j)
Ia_b_angle = arctan(Ia_b.imag/Ia_b.real)  # poosible warning might occur because of division by zero

print('''
EA_b = {:.1f} ∠{:>2.0f}°
Ia_b = {:.1f} ∠{:>2.0f}°
=================='''.format(abs(EA_b), EA_b_angle/pi*180,
                             abs(Ia_b), Ia_b_angle/pi*180))


I am working on the file "Chapman/Ch5-Problem_5-02.ipynb".
The first task is:
Description
Assume that the motor of Problem 5-1 is operating at rated conditions.
Can you write Python code for it?


I am working on the file "Chapman/Ch5-Problem_5-02.ipynb".
The first task is:
The angle of the current is:
Can you write Python code for it?

Ia_angle = arccos(PF)
Ia_angle /pi *180 # [degrees]

Ia = ia * (cos(Ia_angle) + sin(Ia_angle)*1j)
print('''
Ia = {:.0f} A ∠{:.2f}°
=================='''.format(abs(Ia), Ia_angle / pi *180))


I am working on the file "Chapman/Ch5-Problem_5-02.ipynb".
The first task is:
The field current is directly proportional to $|\vec{E}_A|$, which = 480V when $I_F = 4 A$. The required field current is:
$$\frac{|\vec{E}{A2}|}{|\vec{E}{A1}|} = \frac{I_{F2}}{I_{F1}}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch5-Problem_5-02.ipynb".
The first task is:
The internal generated voltage $\vec{E}_A$ is:
$$\vec{E}A = \vec{V}\phi - jX_S\vec{I}_A$$
Can you write Python code for it?

EA = Vt - Xs * 1j * Ia
EA_angle = arctan(EA.imag/EA.real)
print('''
Ea = {:.0f} V ∠{:.1f}°
=================='''.format(abs(EA), EA_angle / pi *180))


I am working on the file "Chapman/Ch5-Problem_5-07.ipynb".
The first task is:
(a)

Find $\vec{V}_\phi$ and $\vec{E}_A$ for these conditions.

(b)

Find the torque angle $\delta$ .

(c)

What is the static stability power limit under these conditions?

(d)

How much field current would be required to make the motor operate at 0.80 PF leading?

(e)

What is the new torque angle in part (d)?

SOLUTION
(a)
The phase voltage of this motor is $V_\phi = 120 V$, and the armature current is $\vec{I}_A = 50\,A \angle 0°$ .
Therefore, the internal generated voltage is:
$$\vec{E}A = \vec{V}\phi - R_A \vec{I}_A - jX_S \vec{I}_A$$
Can you write Python code for it?

Vphi = Vt / sqrt(3)
EA = Vphi - Ra*Ia - Xs*1j*Ia
EA_angle = arctan(EA.imag/EA.real)
print('''
EA = {:.0f} V ∠{:.1f}°
=================='''.format(abs(EA), EA_angle/pi*180))


I am working on the file "Chapman/Ch5-Problem_5-07.ipynb".
The first task is:
(c)
The static stability power limit is given by
$$P_\text{max} = \frac{3V_\phi E_A}{X_S}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch5-Problem_5-07.ipynb".
The first task is:
(d)
A phasor diagram of the motor operating at a power factor of 0.78 leading is shown below.
<img src="figs/Problem_5-07.jpg" width="70%">
Since the power supplied by the motor is constant, the quantity $I_A cos \theta$ , which is directly proportional
to power, must be constant. Therefore,
Can you write Python code for it?

theta1 = 0 # [rad]
theta2 = arccos(PF2)
Ia2 = Ia*cos(theta1) / cos(theta2)
IA2 = Ia2 * (cos(theta2)+sin(theta2)*1j)
IA2_angle = theta2
print('IA2 = {:.1f} A ∠{:.2f}°'.format(abs(IA2), IA2_angle/pi*180))


I am working on the file "Chapman/Ch5-Problem_5-07.ipynb".
The first task is:
The internal generated voltage $E_A$ is directly proportional to the field flux, and we have assumed in this
problem that the flux is directly proportional to the fiel d current. Therefore, the required field current is:
$$I_{F2} = \frac{E_{A2}}{E_{A1}}I_{F1}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch5-Problem_5-07.ipynb".
The first task is:
The internal generated voltage required to produce this current would be:
$$\vec{E}{A2} = \vec{V}\phi - R_A \vec{I}{A2} - jX_S \vec{I}{A2}$$
Can you write Python code for it?

EA2 = Vphi - Ra*IA2 - Xs*1j*IA2
EA2_angle = arctan(EA2.imag/EA2.real)
print('EA2 = {:.0f} V ∠{:.1f}°'.format(abs(EA2), EA2_angle/pi*180))


I am working on the file "Chapman/Ch5-Problem_5-10.ipynb".
The first task is:
Description
A synchronous machine has a synchronous reactance of $1.0\,\Omega$ per phase and an armature resistance of $0.1\,\Omega$ per phase.

If $\vec{E}A = 460\,V\angle-10°$ and $\vec{V}\phi = 480\,V\angle0°$, is this machine a motor or a generator?
How much power P is this machine consuming from or supplying to the electrical system?
How much reactive power Q is this machine consuming from or supplying to the electrical system?
Can you write Python code for it?

Ea         = 460         # [V]
EA_angle   = -10/180*pi  # [rad]
EA         = Ea * (cos(EA_angle) + 1j*sin(EA_angle))
Vphi       = 480         # [V]
VPhi_angle =   0/180*pi  # [rad]
VPhi       = Vphi*exp(1j*VPhi_angle)
Ra         =   0.1       # [Ohm]
Xs         =   1.0       # [Ohm]


I am working on the file "Chapman/Ch5-Problem_5-10.ipynb".
The first task is:
SOLUTION
This machine is a motor, consuming power from the power system, because $\vec{E}A$ is lagging $\vec{V}\phi$
It is also consuming reactive power, because $E_A \cos{\delta} < V_\phi$ . The current flowing in this machine is:
$$\vec{I}A = \frac{\vec{V}\phi - \vec{E}_A}{R_A + jX_s}$$
Can you write Python code for it?

IA = (VPhi - EA) / (Ra + Xs*1j)
IA_angle = arctan(IA.imag/IA.real)
print('IA = {:.1f} A ∠ {:.2f}°'.format(abs(IA), IA_angle/pi*180))


I am working on the file "Chapman/Ch5-Problem_5-10.ipynb".
The first task is:
and the reactive power consumed by this motor is:
$$Q = 3V_\phi I_A \sin{\theta}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Animation_RotorSlipMeasurementWithCompass.ipynb".
The first task is:
Look at a superposition of two sinusoidal signals:
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Animation_RotorSlipMeasurementWithCompass.ipynb".
The first task is:
Now let us take an example with two different angular frequencies:
Can you write Python code for it?

s = 0.03        # slip
fs = 50         # stator frequency in Hz
fr = (1-s)*fs   # rotor frequency in Hz
fr

alpha=2*pi*fs*t
beta=2*pi*fr*t


I am working on the file "Chapman/Ch6-Animation_RotorSlipMeasurementWithCompass.ipynb".
The first task is:
This product can be rewritten as a sum using trigonometric equalities. SymPy has a special function for those:
Can you write Python code for it?

from sympy.simplify.fu import *
g=TR8(f)     # TR8 is a trigonometric expression function from Fu paper
Eq(f, g)


I am working on the file "Chapman/Ch6-Example_6-05d.ipynb".
The first task is:
Calculate torque for doubled rotor resistance:
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Example_6-05d.ipynb".
The first task is:
Calculate torque for original rotor resistance using:
$$ \tau_\text{ind} = \frac{3 V_{TH}^2 R_2 / s}{\omega_\text{sync}[(R_{TH} + R_2/s)^2 + (X_{TH} + X_2)^2]} $$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Example_6-05d.ipynb".
The first task is:
Now calculate the torque-speed characteristic for many slips between 0 and 1.
Can you write Python code for it?

s = linspace(0, 1, 50) # Slip
s[0] = 0.001           # avoid divide-by-zero problems
nm = (1 - s) * n_sync  # mechanical speed


I am working on the file "Chapman/Ch6-Example_6-05d_gen.ipynb".
The first task is:
Calculate the Thevenin voltage and impedance from Equations 7-41a:
$$ V_{TH} =  V_\phi \frac{X_M}{\sqrt{R_1^2 + (X_1 + X_M)^2}} $$
and 7-43:
$$ Z_{TH} = \frac{jX_m (R_1 + jX_1)}{R_1 + j(X_1 + X_M)} $$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Example_6-05d_gen.ipynb".
The first task is:
Calculate torque for triple rotor resistance:
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Example_6-05d_gen.ipynb".
The first task is:
Now calculate the torque-speed characteristic for many slips between -1 and 1.
Can you write Python code for it?

s = linspace(-1, 1, 100)  # slip
nm = (1 - s) * n_sync     # mechanical speed


I am working on the file "Chapman/Ch6-Example_6-05d_gen.ipynb".
The first task is:
Plot the torque-speed curve:
Can you write Python code for it?

rc('text', usetex=True)   # enable LaTeX commands for plot
plot(nm, t_ind1,'b',
     nm, t_ind2,'k--',
     lw=2)
xlabel(r'$\mathbf{n_{m}}\ [rpm]$')
ylabel(r'$\mathbf{\tau_{ind}}\ [Nm]$')
title ('Induction machine torque-speed characteristic')
legend (('Original $R_{2}$', '$3 \cdot R_{2}$',), loc = 1);
grid()


I am working on the file "Chapman/Ch6-Example_6-06.ipynb".
The first task is:
Calculate induced torque for double-cage rotor.
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Example_6-06.ipynb".
The first task is:
Calculate resistance and reactance of the double-cage rotor at this slip, and then use those values to calculate the induced torque.
Can you write Python code for it?

y_r = 1/(r2i + 1j*s*x2i) + 1/(r2o + 1j*s*x2o)
z_r = 1/y_r            # Effective rotor impedance
r2eff = real(z_r)      # Effective rotor resistance
x2eff = imag(z_r)      # Effective rotor reactance


I am working on the file "Chapman/Ch6-Example_6-06.ipynb".
The first task is:
Calculate the Thevenin voltage and impedance from Equations 7-41a:
$$ V_{TH} =  V_\phi \frac{X_M}{\sqrt{R_1^2 + (X_1 + X_M)^2}} $$
and 7-43:
$$ Z_{TH} = \frac{jX_m (R_1 + jX_1)}{R_1 + j(X_1 + X_M)} $$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Example_6-06.ipynb".
The first task is:
First, initialize the values needed in this program.
Can you write Python code for it?

r1  =  0.641               # Stator resistance
x1  =  0.750               # Stator reactance
r2  =  0.300               # Rotor resistance for single cage motor
r2i =  0.400               # Rotor resistance for inner cage of double-cage motor
r2o =  3.200               # Rotor resistance for outercage of double-cage motor
x2  =  0.500               # Rotor reactance for single cage motor
x2i =  3.300               # Rotor reactance for inner cage of double-cage motor
x2o =  0.500               # Rotor reactance for outer cage of double-cage motor
xm  = 26.3                 # Magnetization branch reactance
v_phase =  460 / sqrt(3)    # Phase voltage
n_sync  = 1800              # Synchronous speed (r/min)
w_sync  = n_sync * 2*pi/60  # Synchronous speed (rad/s)


I am working on the file "Chapman/Ch6-Example_6-06.ipynb".
The first task is:
Now calculate the torque-speed characteristic for many slips between 0 and 1.
Can you write Python code for it?

s = linspace(0, 1, 50) # slip
s[0] = 0.001           # avoid divide-by-zero problems
nm = (1 - s) * n_sync  # mechanical speed


I am working on the file "Chapman/Ch6-Example_6-06.ipynb".
The first task is:
Plot the torque-speed curve:
Can you write Python code for it?

rc('text', usetex=True)   # enable LaTeX commands for plot
plot(nm, t_ind1,'b',
     nm, t_ind2,'k--',
     lw=2)
xlabel(r'$\mathbf{n_{m}}\ [rpm]$')
ylabel(r'$\mathbf{\tau_{ind}}\ [Nm]$')
title ('Induction motor torque-speed characteristic')
legend ((r'Single-cage design','Double-cage design'), loc = 3);
grid()


I am working on the file "Chapman/Ch6-Problem_6-01.ipynb".
The first task is:
(b)
The speed of the rotor is:
$$n_m = (1-s)n_\text{sync}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-01.ipynb".
The first task is:
(c)
The slip speed of the rotor is:
$$n_\text{slip} = s \cdot n_\text{sync}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-01.ipynb".
The first task is:
(d)
The rotor frequency is:
$$f_{re} = \frac{p\cdot n_\text{slip}}{120}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-01.ipynb".
The first task is:
Description
A 220-V three-phase six-pole 50-Hz induction motor is running at a slip of 3.5 percent.
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-01.ipynb".
The first task is:
Find:
(a)

The speed of the magnetic fields in revolutions per minute

(b)

The speed of the rotor in revolutions per minute

(c)

The slip speed of the rotor

(d)

The rotor frequency in hertz

SOLUTION
(a)
The speed of the magnetic fields is:
$$n_\text{sync} = \frac{120f_{se}}{P}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-02.ipynb".
The first task is:
(b)
The speed of the rotor is:
$$n_m = (1-s)n_\text{sync}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-02.ipynb".
The first task is:
(c)
The slip speed of the rotor is:
$$n_\text{slip} = s\cdot n_\text{sync}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-02.ipynb".
The first task is:
(d)
The rotor frequency is:
$$f_{re} = \frac{p\cdot n_\text{slip}}{120}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-02.ipynb".
The first task is:
Description
Answer the questions in Problem 6-1 for a 480-V three-phase two-pole 60-Hz induction motor running at a slip of 0.025.
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-02.ipynb".
The first task is:
SOLUTION
(a)
The speed of the magnetic fields is:
$$n_\text{sync} = \frac{120f_{se}}{p}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-03.ipynb".
The first task is:
(a)

How many poles does this motor have?

(b)

What is the slip at rated load?

(c)

What is the speed at one-quarter of the rated load?

(d)

What is the rotor’s electrical frequency at one-quarter of the rated load?

SOLUTION
(a)
This machine produces a synchronous speed of:
$$n_\text{sync} = \frac{120f_e}{p}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-03.ipynb".
The first task is:
(b)
The slip at rated load is:
$$s = \frac{n_\text{sync} - n_m}{n_\text{sync}} \cdot 100\%$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-03.ipynb".
The first task is:
(c)
The motor is operating in the linear region of its torque-speed curve, so the slip at $\frac14$ load will approximatly be:
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-03.ipynb".
The first task is:
(d)
The electrical frequency at $\frac14$ load is:
$$f_r = sf_e$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-03.ipynb".
The first task is:
Description
A three-phase 60-Hz induction motor runs at 715 r/min at no-load and at 670 r/min at full load.
Note:
The no-load speed is near but not identical with the synchronous speed. You will always have some losses that the machine needs to overcome. Hence the speed of the rotor will never reach synchronous speed even with no-load.
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-03.ipynb".
The first task is:
which produces a syncronous speed of
Can you write Python code for it?

n_sync = 120*fe / p
print('n_sync = {:.0f} rpm'.format(n_sync))


I am working on the file "Chapman/Ch6-Problem_6-04.ipynb".
The first task is:
$$\tau_\text{ind} = \frac{P_\text{conv}}{\omega_m}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-04.ipynb".
The first task is:
(b)
The output power in Watts is 50 kW (stated in the problem).
(c)
The load torque is:
$$\tau_\text{load} = \frac{P_\text{OUT}}{\omega_m}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-04.ipynb".
The first task is:
(e)
The rotor frequency is:
$$f_r = sf_{se}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-05.ipynb".
The first task is:
(b)
The stator copper losses are
$$P_\text{SCL} = 3I_A^2R_1$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-05.ipynb".
The first task is:
(c)
The equivalent circuit did not take into account the core losses by way of $R_m$, instead they were explicitely given.
Now the the air gap power is:
$$P_\text{AG} = P_\text{in} - P_\text{SCL} - P_\text{core}$$
$$P_\text{AG} = 3I_2^2\frac{R_2}{s} = 3I_A^2R_F - P_\text{core}$$

Note that $3I_A^2R_F - P_\text{core}$ is equal to $3I_2^2\frac{R_2}{s}$, since the only resistance in the original rotor circuit was $\frac{R_2}{s}$ , and the resistance in the Thevenin equivalent circuit is $R_F$. The power consumed by the Thevenin equivalent circuit should be the same as the power consumed by the original circuit. But the Thevenin circuit we use here is missing the $R_m$ part. As an excercise you could calculate $R_m$ from $P_\text{core}$ and then determin the Thevenin impedance as follows:
$$Z_F = \frac{1}{\frac{1}{R_m} + \frac{1}{jX_M}+\frac{1}{Z_2}}$$
This however is not done here and we simply substract the core losses directly.

Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-05.ipynb".
The first task is:
(e)
The induced torque in the motor is:
$$\tau_\text{ind} = \frac{P_\text{AG}}{\omega_\text{sync}}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-05.ipynb".
The first task is:
(f)
The output power of this motor is:
$$P_\text{OUT} = P_\text{conv} - P_\text{f\&w} - P_\text{core} - P_\text{misc}$$
Can you write Python code for it?

Pout = Pconv - Pfw - Pcore - Pmisc
print('Pout = {:.1f} kW'.format(Pout/1000))


I am working on the file "Chapman/Ch6-Problem_6-05.ipynb".
The first task is:
(g)
The overall efficiency is:
$$\eta = \frac{P_\text{OUT}}{P_\text{IN}} \cdot 100\% = \frac{P_\text{OUT}}{3V_\phi I_A\cos\theta}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-05.ipynb".
The first task is:
The output speed is:
$$n_m = (1-s)n_\text{sync}$$
Can you write Python code for it?

n_m = (1 - s) * n_sync
print('n_m = {:.0f} r/min'.format(n_m))


I am working on the file "Chapman/Ch6-Problem_6-05.ipynb".
The first task is:
The phase voltage is
Can you write Python code for it?

Vphi = V / sqrt(3)
print('Vphi = {:.0f} V'.format(Vphi))


I am working on the file "Chapman/Ch6-Problem_6-05.ipynb".
The first task is:
Therefore the load torque is:
$$\tau_\text{load} = \frac{P_\text{OUT}}{\omega_m}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-05.ipynb".
The first task is:
so line current $I_L$ is:
$$I_L = I_A = \frac{V_\phi}{R_1+jX_1+R_F+jX_F}$$
Can you write Python code for it?

Rf = Zf.real
Xf = Zf.imag
Ia = Vphi / (R1 + X1*1j + Rf + Xf*1j)
Ia_angle = arctan(Ia.imag/Ia.real)
Il = Ia
print('''
Il = Ia = {:.1f} A ∠{:.1f}°
========================''' .format(abs(Il), Ia_angle/pi *180))


I am working on the file "Chapman/Ch6-Problem_6-06.ipynb".
The first task is:
SOLUTION
The slip at pullout torque is found by calculating the Thevenin equivalent of the input circuit from the rotor back to the power supply, and then using that with the rotor circuit model.
<img src="figs/FigC_6-18.jpg" width="70%">
$$Z_{TH} = \frac{jX_M(R_1+jX_1)}{R_1 + j(X_1+X_M)}$$
Can you write Python code for it?

Zth = (Xm*1j * (R1 + X1*1j)) / (R1 + (X1+Xm)*1j)
Zth_angle = arctan(Zth.imag/Zth.real)
print('Zth = ({:.4f})Ω = {:.3f} Ω ∠{:.1f}°'.format(Zth, abs(Zth), Zth_angle/pi*180))


I am working on the file "Chapman/Ch6-Problem_6-06.ipynb".
The first task is:
The pullout torque of the motor is:
$$\tau_\text{max} = \frac{3V_{TH}^2}{2\omega_\text{sync}[R_{TH}+\sqrt{R_{TH}^2+(X_{TH}+X_2)^2}]}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-08.ipynb".
The first task is:
Calculate the Thevenin voltage and impedance:
Can you write Python code for it?

Vth = Vphi * ( Xm / sqrt(R1**2 + (X1 + Xm)**2) )
Zth = ((Xm*1j) * (R1 + X1*1j)) / (R1 + (X1 + Xm)*1j)
Rth = Zth.real
Xth = Zth.imag


I am working on the file "Chapman/Ch6-Problem_6-08.ipynb".
The first task is:
Description
For the motor of Problem 6-5.

How much additional resistance (referred to the stator circuit) would it be necessary to add to the rotor circuit to make the maximum torque occur at starting conditions (when the shaft is not moving)?
Plot the torque-speed characteristic of this motor with the additional resistance inserted.
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-08.ipynb".
The first task is:
Now calculate the torque-speed characteristic for many slips between 0 and 1. Note that the first slip value is set to 0.001 instead of exactly 0 to avoid divide-by-zero problems.
Can you write Python code for it?

n_m = (1 - s) * n_sync
tau_ind= (3 * Vphi**2 * R2/s) / (w_sync * ((Rth + R2/s)**2 + (Xth + X20)**2) )

rc('text', usetex=True)   # enable LaTeX commands for plot
title(r'\bf Induction Motor Torque-Speed Characteristic')
xlabel(r'$n_m$ [r/min]')
ylabel(r'$\tau_{ind}$ [Nm]')
plot(n_m, tau_ind,  linewidth = 2)
grid()


I am working on the file "Chapman/Ch6-Problem_6-08.ipynb".
The first task is:
SOLUTION
To get the maximum torque at starting, the $s_\text{max}$ must be 1.00. Therefore,
$$s_\text{max} = \frac{R_2}{\sqrt{R_{TH}^2+(X_{TH}+X_2)^2}}$$
$R_2$ and $X_2$ are given which means we still need to determine $R_{TH}$ and $X_{TH}$ from:
$$Z_{TH} = \frac{jX_M(R_1+jX_1)}{R_1 + j(X_1+X_M)}$$
Can you write Python code for it?

Zth = (Xm*1j * (R1 + X1*1j)) / (R1 + (X1+Xm)*1j)
Rth = real(Zth)
Xth = imag(Zth)

s_max = 1.0
R2 = s_max * sqrt(Rth**2 + (Xth + X20)**2)
print('R2 = {:.3f} Ω'.format(R2))


I am working on the file "Chapman/Ch6-Problem_6-08.ipynb".
The first task is:
Since the existing resistance is $0.070\,\Omega$, the additional resistance to be added to the rotor circuit is:
Can you write Python code for it?

dR2 = R2 - R20
print('''
dR2 = {:.3f} Ω
============='''.format(dR2))

s = linspace(0,50,51) / 50 # generate an array with 51 values between 0 and 50
s[0] = 0.001  # avoid division by zero


I am working on the file "Chapman/Ch6-Problem_6-10.ipynb".
The first task is:
$$f_\text{r,fl} = sf_e$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-10.ipynb".
The first task is:
$$f_\text{r,nl} = sf_e$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-10.ipynb".
The first task is:
Description
A three-phase 60-Hz two-pole induction motor runs at a no-load speed of 3580 r/min and a full-load speed of 3440 r/min.

Calculate the slip and the electrical frequency of the rotor at no-load and full-load conditions.
What is the speed regulation of this motor?
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-10.ipynb".
The first task is:
SOLUTION
The synchronous speed of this machine is:
$$n_\text{sync} = \frac{120f_{se}}{p}$$
Can you write Python code for it?

n_sync = 120*fe / p
print('n_sync = {:.0f} r/min'.format(n_sync))


I am working on the file "Chapman/Ch6-Problem_6-10.ipynb".
The first task is:
The slip and electrical frequency at full load conditions is:
$$ S_\text{fl} = \frac{n_\text{sync} - n_\text{fl}}{n_\text{sync}} \cdot 100\%$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-10.ipynb".
The first task is:
The slip and electrical frequency at no-load conditions is:
$$S_\text{nl} = \frac{n_\text{sync} - n_\text{nl}}{n_\text{sync}} \cdot 100\%$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-10.ipynb".
The first task is:
The speed regulation is:
$$SR = \frac{n_\text{nl} - n_\text{fl}}{n_\text{fl}} \cdot 100\%$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-11.ipynb".
The first task is:
The power converted from electrical to mechanical form is:
$$P_\text{conv} = (1-s)P_{AG}$$
Can you write Python code for it?

Pconv = (1-s_nl) * Pag
print('Pconv = {:.0f} W'.format(Pconv))


I am working on the file "Chapman/Ch6-Problem_6-11.ipynb".
The first task is:
The slip of the rotor is:
$$s_{nl} = \frac{n_\text{sync}-n_{nl}}{n_\text{sync}} \cdot 100\%$$
Can you write Python code for it?

s_nl = (n_sync - n_nl) / n_sync
print('s_nl = {:.2f} %'.format(s_nl*100))


I am working on the file "Chapman/Ch6-Problem_6-11.ipynb".
The first task is:
What is the rotor copper loss in this motor?

SOLUTION
This synchronous speed of this motor is:
$$n_\text{sync} = \frac{120f_{se}}{p}$$
Can you write Python code for it?

n_sync = 120*fse / p
print('n_sync = {:.0f} r/min'.format(n_sync))


I am working on the file "Chapman/Ch6-Problem_6-20.ipynb".
The first task is:
At a frequency of 60 Hz,
Can you write Python code for it?

Xlr = (60 / flr) *X_lr
print('Xlr = {:.3f} Ω @ 60 Hz'.format(Xlr))


I am working on the file "Chapman/Ch6-Problem_6-20.ipynb".
The first task is:
Description
A 208-V six-pole Y-connected 25-hp design class B induction motor is tested in the laboratory, with the following results:

No load: 208 V, 24.0 A, 1400 W, 60 Hz
Locked rotor: 24.6 V, 64.5 A, 2200 W, 15 Hz
Dc test: 13.5 V, 64 A

Based on those measurements:

Find the equivalent circuit of this motor, and plot its torque-speed characteristic curve.
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-20.ipynb".
The first task is:
For a Design Class B motor, the split is $X_1 = 0.4 \cdot X_{LR}$ and $X_2 = 0.6 \cdot X_{LR}$ .
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-20.ipynb".
The first task is:
In the locked-rotor test, the line voltage is 24.6 V, so the phase voltage is:
Can you write Python code for it?

Vlr_phase = Vlr / sqrt(3)
print('Vlr_phase = {:.1f} V'.format(Vlr_phase))


I am working on the file "Chapman/Ch6-Problem_6-20.ipynb".
The first task is:
Now calculate the torque-speed characteristic for many slips between 0 and 1. Note that the first slip value is set to 0.001 instead of exactly 0 to avoid divide-by-zero problems.
Can you write Python code for it?

s = linspace(0,50,51) / 50 # generate an array with 51 values between 0 and 50
s[0] = 0.001               # avoid division by zero
p = 6                      # number of poles
n_sync = 60/(p/2) * fnl    # [r/min]
w_sync = 2*pi/60 *n_sync   # [rad/s]
nm = (1-s) * n_sync


I am working on the file "Chapman/Ch6-Problem_6-20.ipynb".
The first task is:
SOLUTION
From the DC test,
<img src="figs/Problem_6-20a.jpg" width="30%">
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-20.ipynb".
The first task is:
The resulting equivalent circuit is shown below:
<img src="figs/Problem_6-20b.jpg" width="70%">
Plotting the torque-speed characteristic:
Calculate the Thevenin voltage and impedance:
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-20.ipynb".
The first task is:
Therefore,
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-21.ipynb".
The first task is:
(b)
The stator power factor is:
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-21.ipynb".
The first task is:
(e)
The stator copper losses are:
$$P_{SCL} = 3I^2_AR_1$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-21.ipynb".
The first task is:
(f)
The air gap power is:
$$P_{AG} = P_\text{in} - P_{SCL} =  3I^2_2\frac{R_2}{s} =  3I^2_A R_F$$
As noted earlier $P_\text{core}$ losses are lumbed into the rotational losses on the rotor side.

Note that $3I_A^2R_F$ is equal to $3I_2^2\frac{R_2}{s}$, since the only resistance in the original rotor circuit was $\frac{R_2}{s}$ , and the resistance in the Thevenin equivalent circuit is $R_F$. The power consumed by the Thevenin equivalent circuit must be the same as the power consumed by the original circuit.

Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-21.ipynb".
The first task is:
(h)
The synchronous speed of this motor is:
$$n_\text{sync} = \frac{120f_{se}}{P}$$
Can you write Python code for it?

n_sync = 120*fse / p
w_sync = n_sync * (2*pi/60.0)
print('''
n_sync = {:.0f} r/min
w_sync = {:.1f} rad/s'''.format(n_sync, w_sync))


I am working on the file "Chapman/Ch6-Problem_6-21.ipynb".
The first task is:
(i)
The output power of this motor is:
$$P_\text{out} = P_\text{conv} - P_\text{f\&w} - P_\text{core} - P_\text{misc}$$
As you can see we are now taking into account the $P_\text{core}$ losses again which we ignored earlier on the electrical side.
Can you write Python code for it?

Pout = Pconv - Pf_w - Pcore - Pmisc
print('Pout = {:.2f} kW'.format(Pout/1000))


I am working on the file "Chapman/Ch6-Problem_6-21.ipynb".
The first task is:
(j)
The overall efficiency is:
$$\eta = \frac{P_\text{out}}{P_\text{in}} = \frac{P_\text{out}}{3V_\phi I_A\cos\theta}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-21.ipynb".
The first task is:
(l)
The power flow diagram can be calculated from:
$$P_\text{out} = P_\text{in} - P_\text{SCL} - P_\text{RCL} - P_\text{f\&w} - P_\text{core} - P_\text{misc}$$
This means we still need to calulate $P_\text{in}$ and $P_\text{RCL}$:
Can you write Python code for it?

Pin = sqrt(3)* V * abs(Il) * PF
Prcl = 3 * abs(Ia)**2 * R2


I am working on the file "Chapman/Ch6-Problem_6-21.ipynb".
The first task is:
Description
A 460-V, 10 hp, four-pole, Y-connected, Insulation class F, Service Factor 1.15 induction motor has the following parameters:
| Stator                | Rotor                 | Power                    |
|-----------------------|-----------------------|--------------------------|
| $R_1 = 0.540\,\Omega$ | $R_2 = 0.488\,\Omega$ | $P_\text{core} = 150\,W$ |
| $X_1 = 2.093\,\Omega$ | $X_2 = 3.209\,\Omega$ | $P_\text{f\&w} = 150\,W$ |
| $X_M = 51.12\,\Omega$ |                       | $P_\text{misc} = 50\,W$  |
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-21.ipynb".
The first task is:
For a slip of 0.02, find
(a)

The line current $I_L$

(b)

The stator power factor

(c)

The rotor power factor

(d)

The rotor frequency

(e)

The stator copper losses $P_{SCL}$

(f)

The air-gap power $P_{AG}$

(g)

The power converted from electrical to mechanical form $P_{conv}$

(h)

The induced torque $\tau_{ind}$

(i)

The load torque $\tau_{load}$

(j)

The overall machine efficiency $\eta$

(k)

The motor speed in revolutions per minute and radians per second

(l)

Sketch the power flow diagram for this motor.

SOLUTION
The equivalent circuit of this induction motor is shown below:

(a)
The easiest way to find the line current (or armature current) is to get the equivalent impedance $Z_F$ of the rotor circuit in parallel with $jX_M$, and then calculate the current as the phase voltage divided by the sum of the series impedances, as shown below.

Note that in this case we are ignoring the $P_\text{core}$ losses in the electrical calculations but we will consider them as part of the rotational losses later on. This is quite common practice as it is hard to determine the $P_\text{core}$ separate from the $P_\text{f\&w}$ losses in practice.

The equivalent impedance of the rotor circuit in parallel with $jX_M$ is:
$$Z_F = \frac{1}{\frac{1}{jX_M} + \frac{1}{Z_2}}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-21.ipynb".
The first task is:
The diagram can then be created:
Can you write Python code for it?

# This demonstrates how to create a simple diagram by implicitly calling the
# Sankey.add() method and by appending finish() to the call to the class.
from matplotlib.sankey import Sankey
sankey = Sankey(unit='W', scale= 1/Pin, format='%.0f', margin=0.25)
sankey.add(flows=[Pin, -Pag, -Pscl],
           labels=['$P_{in}=\sqrt{3}V_TI_LPF$', '$P_{AG}$', '$P_{scl}$'],
           orientations=[ 0, 0, -1],
           pathlengths=[0, 0.1, 0.6])
sankey.add(flows=[Pag, -Pconv, -Prcl],
           labels=[None, '$P_{conv}$',  '$P_{rcl}$'],
           orientations=[ 0, 0, -1],
           pathlengths=[0, 0.1, 0.5],
           prior=0, connect=(1, 0))
sankey.add(flows=[Pconv, -Pout, -Pmisc, -Pf_w, -Pcore],
           labels=[None,'$P_{out}$', '$P_{misc}$', '$P_{f&w}$', '$P_{core}$'],
           orientations=[ 0, 0, -1, -1, -1,],
           pathlengths=[0, 0.1, 0.1, 0.3, 0.45],
           prior=1, connect=(1, 0))
sankey.finish()
title("Sankey diagram of the power-flow");


I am working on the file "Chapman/Ch6-Problem_6-21.ipynb".
The first task is:
The output speed is:
$$n_m = (1-s)n_\text{sync}$$
Can you write Python code for it?

n_m = (1-s) * n_sync
print('n_m = {:.0f} r/min'.format(n_m))


I am working on the file "Chapman/Ch6-Problem_6-21.ipynb".
The first task is:
The phase voltage is:
Can you write Python code for it?

V_phase = V / sqrt(3)
print('V_phase = {:.0f} V'.format(V_phase))


I am working on the file "Chapman/Ch6-Problem_6-21.ipynb".
The first task is:
Therefore the induced torque in the motor is:
$$\tau_\text{ind} = \frac{P_{AG}}{\omega_\text{sync}}$$
Can you write Python code for it?

tau_ind = Pag / w_sync
print('''
tau_ind = {:.1f} Nm
================='''.format(tau_ind))


I am working on the file "Chapman/Ch6-Problem_6-21.ipynb".
The first task is:
so the line current $I_L$ is:
$$I_L = I_A = \frac{V_\phi}{R_1 + jX_1 +R_F + jX_F}$$
Can you write Python code for it?

Il = V_phase / (R1 + X1*1j + Zf)
Ia = Il
Il_angle = arctan(Il.imag/Il.real)
Ia_angle = Il_angle
print('''
Il = {:.2f} A ∠{:.1f}°
===================='''.format(abs(Il), Il_angle/pi *180))


I am working on the file "Chapman/Ch6-Problem_6-25.ipynb".
The first task is:
I.e., $V_{\phi,Y\text{-start}} = V_{\phi,\Delta\text{-run}}/\sqrt{3}$
(b)
The starting phase current will also decrease to same percentage of the normal starting current as the phase voltage does.

For the $\Delta$-connection: $I_{L,\Delta} = \sqrt{3}I_{\phi,\Delta}$

For the Y-connection: $I_{L,Y} = I_{\phi,Y}$

But, $I_{\phi,\Delta} = \sqrt{3}I_{\phi,Y}$ because of  $V_{L_Y} = \sqrt{3}V_{\phi_Y}$ gives:
$$I_{L,\Delta} = \sqrt{3}I_{\phi,\Delta} = \sqrt{3} \cdot \sqrt{3}I_{L,Y}  = \mathbf{3} \cdot I_{L,Y} $$
Can you write Python code for it?

Ild_Iphid = sqrt(3)
Ily_Iphiy = 1
Iphid_Iphiy = sqrt(3)
Ild_Ily = Ild_Iphid * Iphid_Iphiy / Ily_Iphiy
print('''
Ild = {:.0f} Ily
==========='''.format(Ild_Ily))


I am working on the file "Chapman/Ch6-Problem_6-26.ipynb".
The first task is:
SOLUTION
(a)
The starting torque of an induction motor is proportional to the square of $V_{TH}$ ,
$$\frac{\tau_\text{start2}}{\tau_\text{start1}} = \left(\frac{V_\text{TH2}}{V_\text{TH1}}\right)^2 = \left(\frac{V_\text{T2}}{V_\text{T2}}\right)^2$$
If a torque of 1.75 $\tau_{rated}$ is produced by a voltage of 460 V, then a torque of 1.00 $\tau_\text{rated}$ would be produced by a voltage of:
$$\frac{1.00\tau_\text{rated}}{1.75\tau_\text{rated}} = \left(\frac{V_{T2}}{460V}\right)^2$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-26.ipynb".
The first task is:
The input power to this motor is:
$$P_\text{in} = \frac{P_\text{out}}{\eta}$$
Can you write Python code for it?

Pin = Pout / eta
print('Pin = {:.1f} kW'.format(Pin/1000))


I am working on the file "Chapman/Ch6-Problem_6-26.ipynb".
The first task is:
The rated current is equal to:
$$I_\text{rated} = \frac{P_\text{in}}{\sqrt{3}V_TPF}$$
Can you write Python code for it?

Irated = Pin / (sqrt(3)*Vt*PF)
print('Irated = {:.2f} A'.format(Irated))


I am working on the file "Chapman/Ch6-Problem_6-26.ipynb".
The first task is:
so the current drawn from the supply will be:
$$I_\text{line} = \frac{I_\text{start}}{a}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-31.ipynb".
The first task is:
$$\vec{V}{TH} = \frac{jX_M}{R_1 + j(X_1 +X_M)}\vec{V}\phi$$
Can you write Python code for it?

V_PHASE = V / sqrt(3)
VTH = (Xm*1j) / (R1 + (X1 + Xm)*1j) * V_PHASE
VTH_angle = arctan(VTH.imag / VTH.real)
print('VTH = {:.0f} V ∠{:.2f}°'
      .format(abs(VTH), VTH_angle/pi *180))


I am working on the file "Chapman/Ch6-Problem_6-31.ipynb".
The first task is:
(b)
The frequency of the rotor before plugging is:
$$f_r = sf_s$$
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-31.ipynb".
The first task is:
(e)
The frequency of the rotor after plugging is
$$f_r = sf_e$$
Can you write Python code for it?

fr_after = s_after * fse
print('''
fr_after = {:.1f} Hz
==================='''.format(fr_after))


I am working on the file "Chapman/Ch6-Problem_6-31.ipynb".
The first task is:
Description
When it is necessary to stop an induction motor very rapidly, many induction motor controllers reverse the direction of rotation of the magnetic fields by switching any two stator leads. When the direction of rotation of the magnetic fields is reversed, the motor develops an induced torque opposite to the current direction of rotation, so it quickly stops and tries to start turning in the opposite direction. If power is removed from the stator circuit at the moment when the rotor speed goes through zero, then the motor has been stopped very rapidly. This technique for rapidly stopping an induction motor is called plugging . The motor of Problem 6-21 is running at rated conditions and is to be stopped by plugging.
(a)

What is the slip s before plugging?

(b)

What is the frequency of the rotor before plugging?

(c)

What is the induced torque $\tau_\text{ind}$ before plugging?

(d)

What is the slip s immediately after switching the stator leads?

(e)

What is the frequency of the rotor immediately after switching the stator leads?

(f)

What is the induced torque $\tau_\text{ind}$ immediately after switching the stator leads?
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-31.ipynb".
The first task is:
SOLUTION
(a)
The slip before plugging is (see Problem 6-21).
Can you write Python code for it?


I am working on the file "Chapman/Ch6-Problem_6-31.ipynb".
The first task is:
The induced torque immediately after switching the stator leads is:
$$\tau_\text{ind} = \frac{3V^2_{TH}R_2/s}{\omega_\text{sync}[(R_{TH} + R_2/s)^2 + (X_{TH} + X_2)^2]}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch7-Problem_7-01.ipynb".
The first task is:
(c)
If the speed of the rotor were increased to 550 rad/s, the induced voltage of the loop would increase to:
Can you write Python code for it?

w_c = 550 # [rad/s]
e_ind_c = 2*r*l*B*w_c
e_ind_c


I am working on the file "Chapman/Ch7-Problem_7-01.ipynb".
The first task is:
(d)
If the speed of the rotor were decreased to 450 rad/s, the induced voltage of the loop would fall to:
Can you write Python code for it?

w_d = 450 # [rad/s]
e_ind_d = 2*r*l*B*w_d
e_ind_d


I am working on the file "Chapman/Ch7-Problem_7-01.ipynb".
The first task is:
Description
The following information is given about the simple rotating loop shown in Figure 7-6:
<img src="figs/FigC_7-6.jpg" width="70%">
\begin{equation}
\begin{array}{ll}
B = 0.4\,T  &    V_B = 48\,V \
l = 0.5\,m  &      R = 0.4\,\Omega \
r = 0.25\,m & \omega = 500\,rad/s
\end{array}
\end{equation}
Can you write Python code for it?


I am working on the file "Chapman/Ch7-Problem_7-01.ipynb".
The first task is:
Since the external battery voltage is only 48 V, this machine is operating as a generator, charging the
battery.
(b)
The current flowing out of the machine is approximately:
$$i = \frac{e_\text{ind} - V_B}{R}$$

Note that this value is the current flowing while the loop is under the pole faces. When the loop goes
beyond the pole faces, $e_\text{ind}$ will momentarily fall to 0 V, and the current flow will momentarily reverse.
Therefore, the average current flow over a complete cycle will be somewhat less than 5.0 A.

Can you write Python code for it?


I am working on the file "Chapman/Ch7-Problem_7-01.ipynb".
The first task is:
Volts. Here, $e_\text{ind}$ is less than $V_B$ , so current flows into the loop and the machine is acting as a motor. The current
flow into the machine would be:
$$i = \frac{V_B - e_\text{ind}}{R}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
(a)
If $V_A = 120\,V$, then $E_A =\,120 V$
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
(b)
If $V_A = 180\,V$, then $E_A = 180\,V$
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
(b)
The minimum speed will occur with the maximum $V_A$ and the maximum $R_\text{adj}$. The field current for $R_\text{adj} = 100 \Omega$ is:
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:

For Problems 8-8 and 8-9, the shunt dc motor is reconnected separately excited, as shown in Figure P8-3.
It has a fixed field voltage $V_F$ of 240 V and an armature voltage $V_A$ that can be varied from 120 to 240 V.

Problem 8-8
Description
What is the no-load speed of this separately excited motor when $R_\text{adj} = 175\, \Omega$ and
(a)
$V_A = 120\,V$
(b)
$V_A = 180\,V$
(c)
$V_A = 240\,V$
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Calculate the armature current for each load
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Calculate the effective field current with and without armature reaction. Ther term If_ar is the field current with armature reaction, and the term If_noar is the field current without armature reaction.
Can you write Python code for it?

If_ar = Vt / (Rf + Radj_7) - f_ar_7 / Nf;
If_noar = Vt / (Rf + Radj_7);


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Calculate the induced torque corresponding to each speed from Equation (8-10).
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Calculate the resulting internal generated voltage at $n_0$ by interpolating the motor's magnetization curve.
Can you write Python code for it?

Ea0_ar_7 = interp(If_ar, data['If_values'], data['Ea_values'])
Ea0_noar_7 = interp(If_noar, data['If_values'], data['Ea_values'])


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Calculate the resulting speed from Equation (8-13)
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Description
Problems 8-1 to 8-12 refer to the following dc motor:
| .                            | .                                          |
|------------------------------|--------------------------------------------|
| $P_\text{rated} = 30\,hp$    | $I_\text{L,rated} = 110\,A$                |
| $V_T = 240\,V$               | $n_\text{rated} = 1800\,r/min$             |
| $R_A = 0.19\,\Omega$         | $R_S = 0.02\,\Omega$                       |
| $N_F = 2700 \text{turns per pole}$ | $N_{SE} = 14 \text{ turns per pole}$ |
| $R_F = 75\,\Omega$           | $R_\text{adj} = 100\text{ to }400\,\Omega$ |
Rotational losses = 3550 W at full load.
Magnetization curve as shown in Figure P8-1:

Note:
An electronic version of this magnetization curve can be found in file
p81_mag.dat, which can be used with Python programs. Column 1
contains field current in amps, and column 2 contains the internal generated
voltage $E_A$ in volts.

In Problems 8-1 through 8-7, assume that the motor described above can be connected in shunt.
The equivalent circuit of the shunt motor is shown in Figure P8-2.

Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
First, initialize the values needed in this program.
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
From Figure P8-1, this field current would produce an internal generated voltage $E_{A0}$ of 185 V at a speed $n_0$ of
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
From Figure P8-1, this field current would produce an internal generated voltage $E_{A0}$ of 241 V at a speed
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
From Figure P8-1, this field current would produce an internal generated voltage $E_{A0}$ of 271.5 V at a speed
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
From Figure P8-1, this field current would produce an internal generated voltage $E_{A_0}$ of 167 V at a speed
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
From Figure P8-1, this field current would produce an internal generated voltage $E_{A_0}$ of 241 V at a speed $n_0$ of 1800 r/min. Therefore, the speed n with a voltage $E_A$ of 240 V would be:
$$\frac{E_A}{E_{A_0}} = \frac{n}{n_0}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
From Figure P8-1, this field current would produce an internal generated voltage $E_{Ao}$ of 271 V at a speed
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
If all other conditions are the same, the motor with armature reaction runs at a higher speed than the motor
without armature reaction.
Problem 8-5
Description
If $R_\text{adj}$ can be adjusted from 100 to 400 $\Omega$

What are the maximum and minimum no-load speeds possible with this motor?
Can you write Python code for it?

Radj_5_min = 100 # [Ohm]
Radj_5_max = 400 # [Ohm]


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Note that $R_\text{adj}$ has increased, and as a result the speed of the motor $n$ increased.
Problem 8-4
Description
Assume that the motor is operating at full load and that the variable resistor $R_\text{adj}$ is again $175\,\Omega$ .
If the armature reaction is $1000\, A\cdot t$ at full load,

What is the speed of the motor?
How does it compare to the result for Problem 8-2?
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Now calculate the internal generated voltage for each armature current.
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Plot the torque-speed curves
Can you write Python code for it?

title(r'Shunt DC Motor Torque-Speed Characteristic')
xlabel(r'$\tau_{ind}$ [Nm]')
ylabel(r'$n_m$ [r/min]')
plot(tau_ind_noar_7, n_noar_7, tau_ind_ar_7, n_ar_7)
legend(('No armature reaction', 'With armature reaction'), loc=1)
grid()


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Problem 8-1
Description
If the resistor $R_\text{adj}$ is adjusted to $175\,\Omega$

What is the rotational speed of the motor at no-load conditions?

SOLUTION
At no-load conditions, $E_A = V_T = 240 V$ . The field current is given by:
$$I_F = \frac{V_T}{R_\text{adj}+R_F}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Problem 8-3
Description
If the motor is operating at full load and if its variable resistance $R_\text{adj}$ is increased to $250\,\Omega$,

What is the new speed of the motor?
Compare the full-load speed of the motor with $R_\text{adj} = 175\,\Omega$ to the full-load speed with $R_\text{adj} = 250\,\Omega$. (Assume no armature reaction, as in the previous problem.)

SOLUTION
If $R_\text{adj}$ is set to $250\,\Omega$, the field current is now:
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Problem 8-6
Description

What is the starting current of this machine if it is started by connecting it directly to the power supply $V_T$ ?
How does this starting current compare to the full-load current of the motor?

SOLUTION
The starting current of this machine (ignoring the small field current) is:
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Problem 8-9
Description
For the separately excited motor of Problem 8-8:
(a)

What is the maximum no-load speed attainable by varying both $V_A$ and $R_\text{adj}$ ?

(b)

What is the minimum no-load speed attainable by varying both $V_A$ and $R_\text{adj}$ ?

(c)

What is the motor’s efficiency at rated conditions?

Note:
Assume that
(1) the brush voltage drop is 2 V;
(2) the core loss is to e determined at an armature voltage equal to the armature voltage under full load;
(3) stray load losses are 1 percent of full load.

SOLUTION
(a)
The maximum speed will occur with the maximum $V_A$ and the maximum $R_\text{adj}$. The field current for $R_\text{adj} = 400\,\Omega$ is:
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
SOLUTION
The field current is again 0.96 A, and the motor is again at full load conditions. However, this
time there is an armature reaction of $1200 A \cdot turns$, and the effective field current is:
$$I_F^* = I_F - \frac{AR}{N_F}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Since the motor is still at full load, $E_A$ is still
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Therefore, the speed n with a voltage of 240 V would be:
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
V. From the magnetization curve (Figure P8-1), the new field current $I_F$ would produce a voltage $E_{A_0}$ of 212 V at a speed:
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Volts would be:
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
Volts. The field current is the same as before, and there is no armature reaction, so $E_{A_0}$ is still 241 V at a speed $n_0$ of 1800 r/min. Therefore,
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
r/min. At no-load conditions, the maximum internal generated voltage $E_A = V_A = 240\,V$.
Therefore, the speed $n$ with a voltage of 240 V would be:
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
r/min. The actual internal generated voltage $E_A$ at these conditions is:
$$E_A = V_T - I_A R_A$$
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
r/min. Therefore, the speed n with a voltage of
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
rpm. The speed regulation is:
$$SR = \frac{n_\text{nl}-n_\text{fl}}{n_\text{fl}}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-01to09.ipynb".
The first task is:
times greater than the full-load current. This much current is extremely likely to damage the motor.
Problem 8-7
Description
Plot the torque-speed characteristic of this motor assuming no armature reaction, and again assuming a full-load armature reaction of $1200\, A \cdot turns$. (Assume that the armature reaction increases linearly with increases in armature current.)
SOLUTION
This problem is best solved with a script, since it involves calculating the torque-speed
values at many points.
Get the magnetization curve. Note that this curve is defined for a speed of 1200 r/min.
Can you write Python code for it?

# Load the magnetization curve data
import pandas as pd
# The data file is stored in the repository
fileUrl = 'data/p81_mag.dat'
data = pd.read_csv(fileUrl,     # the address where to download the datafile from
                   sep=' ',     # our data source uses a blank space as separation
                   comment='%', # ignore lines starting with a "%"
                   skipinitialspace = True,  # ignore intital spaces
                   header=None, # we don't have a header line defined...
                   names=['If_values', 'Ea_values'] # ...instead we define the names here
                   )


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
At full load conditions, the armature current is:
Can you write Python code for it?

Ia_11 = Il_rated - Vt/(Radj_11 + Rf)
Ia_11


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
Calculate the armature current for each load
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
Calculate the resulting speed from Equation (8-13)
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
Description
|                                     |                                            |
|-------------------------------------|--------------------------------------------|
| $P_\text{rated} = 30\,hp$           | $I_\text{L,rated} = 110\,A$                |
| $V_T = 240\,V$                      | $n_\text{rated} = 1800\,r/min$             |
| $R_A = 0.19\,\Omega$                | $R_S = 0.02\,\Omega$                       |
| $N_F = 2700 \text{ turns per pole}$ | $N_{SE} = 14 \text{ turns per pole}$       |
| $R_F = 75\,\Omega$                  | $R_\text{adj} = 100\text{ to }400\,\Omega$ |
Rotational losses = 3550 W at full load.
Magnetization curve as shown in Figure P8-1.

Note:
An electronic version of this magnetization curve can be found in file p81_mag.dat, which can be used with Python programs. Column 1
contains field current in amps, and column 2 contains the internal generated
voltage $E_A$ in volts.

For Problems 8-10 to 8-11, the motor is connected cumulatively compounded as shown in Figure P8-4.

Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
First, initialize the values needed in this program.
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
From Figure P8-1, this field current would produce an internal generated voltage $E_{A_0}$ of 268 V at a speed
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
From Figure P8-1, this field current would produce an internal generated voltage $E_{A_0}$ of 279 V at a speed
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
Now calculate the internal generated voltage for each armature current.
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
Plot the torque-speed curves
Can you write Python code for it?

title(r'Shunt DC Motor Torque-Speed Characteristic')
xlabel(r'$\tau_{ind}$ [Nm]')
ylabel(r'$n_m$ [r/min]')
axis([ 0, 170 ,1390,1810])   #set the axis range
plot(tau_ind_10,n_10)
grid()


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
Problem 8-11
Description
The motor is connected cumulatively compounded and is operating at full load.

What will the new speed of the motor be if $R_\text{adj}$ is increased to $250\,\Omega$ ?
How does the new speed compared to the full-load speed calculated in Problem 8-10?
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
SOLUTION
At no-load conditions, $E_A = V_T = 240 V$ . The field current is given by:
$$I_F = \frac{V_T}{R_\text{adj}+R_F}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
SOLUTION
If $R_\text{adj}$ is increased to $250\,\Omega$ , the field current is given by:
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
The equivalent field current is:
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
The internal generated voltage $E_A$ is:
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
The torque-speed characteristic can best be plotted with a Python program. An appropriate program is
shown below.
Get the magnetization curve. Note that this curve is defined for a speed of 1200 r/min.
Can you write Python code for it?

#Load the magnetization curve data
import pandas as pd
# The data file is stored in the repository
fileUrl = 'data/p81_mag.dat'
data = pd.read_csv(fileUrl,     # the address where to download the datafile from
                   sep=' ',     # our data source uses a blank space as separation
                   comment='%', # ignore lines starting with a "%"
                   skipinitialspace = True,  # ignore intital spaces
                   header=None, # we don't have a header line defined...
                   names=['If_values', 'Ea_values'] # ...instead we define the names here
                   )


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
r/min. Therefore, the speed n with a voltage $E_A$ of 240 V would be:
$$\frac{E_A}{E_{A_0}} = \frac{n}{n_0}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-10to11.ipynb".
The first task is:
r/min. Therefore, the speed n with a voltage $E_A$ of 240 V would be:
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-22.ipynb".
The first task is:
Amperes. From the magnetization curve, the voltage $E_{Ao}$ at 1800 r/min is 135 V.
Since the actual speed is 1800r/min, the maximum no-load voltage is 135 V.
The minimum possible field current occurs when $R_\text{adj} = 40\,\Omega$.
The current is:
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-22.ipynb".
The first task is:
Amperes. From the magnetization curve, the voltage $E_{Ao}$ at 1800 r/min is 79.5 V.
Since the actual speed is 1800r/min, the minimum no-load voltage is 79.5 V.
(b)
The maximum voltage will occur at the highest current and speed, and the minimum voltage will
occur at the lowest current and speed. The maximum possible field current occurs when $R_\text{adj} = 0\,\Omega$.
The current is
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-22.ipynb".
The first task is:
Description
The magnetization curve for a separately excited dc generator is shown in Figure P8-7. The generator is
rated at 6 kW, 120 V, 50 A, and 1800 r/min and is shown in Figure P8-8. Its field circuit is rated at 5A.

Note
An electronic version of this magnetization curve can be found in file
p87_mag.dat , which can be used with Python programs. Column 1
contains field current in amps, and column 2 contains the internal generated
voltage $E_A$ in volts.

The following data are known about the machine:
$$R_A = 0.18\,\Omega \qquad \quad V_F = 120\,V$$
$$R_\text{adj} = 0\text{ to }40\,\Omega \qquad R_F = 20\, \Omega$$
$$N_F = 1000 \text{ turns per pole}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-22.ipynb".
The first task is:
From the magnetization curve, the voltage $E_{Ao}$ at 1800 r/min is 135 V. Since the actual speed is 2000
r/min, the maximum no-load voltage is:
$$\frac{E_A}{E_{A0}} = \frac{n}{n_0}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch8-Problem_8-22.ipynb".
The first task is:
The minimum possible field current occurs and minimum speed and field current. The maximum adjustable resistance is $R_\text{adj} = 30\,\Omega$.
The current is
Can you write Python code for it?

Radj_max_b = 30.0 # [Ohm]
If_min = Vf / (Rf + Radj_max_b)
If_min


I am working on the file "Chapman/Ch9-Problem_9-01.ipynb".
The first task is:
(a)
The input current is:
$$\vec{I}_1 = \frac{\vec{V}}{R_1 + jX_1 + 0.5Z_F + 0.5Z_B}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-01.ipynb".
The first task is:
(b)
The air-gap power is:
Can you write Python code for it?

Pag_f = abs(I1)**2*0.5*Zf.real
Pag_f

Pag_b = abs(I1)**2*0.5*Zb.real
Pag_b

Pag = Pag_f - Pag_b
print('''
Pag = {:.0f} W
==========='''.format(Pag))


I am working on the file "Chapman/Ch9-Problem_9-01.ipynb".
The first task is:
(c)
The power converted from electrical to mechanical form is:
Can you write Python code for it?

Pconv_f = (1-s)*Pag_f
Pconv_f

Pconv_b = (1-s)*Pag_b
Pconv_b

Pconv = Pconv_f - Pconv_b
print('''
Pconv = {:.0f} W
============='''.format(Pconv))


I am working on the file "Chapman/Ch9-Problem_9-01.ipynb".
The first task is:
(d)
The output power is:
Can you write Python code for it?

Pout = Pconv - Prot
print('''
Pout = {:.0f} W
============'''.format(Pout))


I am working on the file "Chapman/Ch9-Problem_9-01.ipynb".
The first task is:
(e)
The induced torque is
$$\tau_\text{ind} = \frac{P_\text{AG}}{\omega_\text{sync}}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-01.ipynb".
The first task is:
(f)
The load torque is:
$$\tau_\text{load} = \frac{P_\text{out}}{\omega_m}$$
Can you write Python code for it?

w_m = (1-s)*w_sync
tau_load = Pout / w_m
print('''
τ_load = {:.2f} Nm
================'''.format(tau_load))


I am working on the file "Chapman/Ch9-Problem_9-01.ipynb".
The first task is:
(g)
The overall efficiency is:
$$\eta = \frac{P_\text{out}}{P_\text{in}} \cdot 100\%$$
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-01.ipynb".
The first task is:
(h)
The stator power factor is:
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-02.ipynb".
The first task is:
$$Z_B = \frac{(R_2/(2-s) + jX_2)(jX_M)}{R_2/(2-s) + jX_2 + jX_M}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-02.ipynb".
The first task is:
(a)
The input current is:
$$\vec{I}_1 = \frac{\vec{V}}{R_1 + jX_1 + 0.5Z_F + 0.5Z_B}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-02.ipynb".
The first task is:
(b)
The air-gap power is:
Can you write Python code for it?

Pag_f = abs(I1)**2*0.5*Zf.real
Pag_f

Pag_b = abs(I1)**2*0.5*Zb.real
Pag_b

Pag = Pag_f - Pag_b
print('''
Pag = {:.1f} W
============='''.format(Pag))


I am working on the file "Chapman/Ch9-Problem_9-02.ipynb".
The first task is:
(c)
The power converted from electrical to mechanical form is:
Can you write Python code for it?

Pconv_f = (1-s)*Pag_f
Pconv_f

Pconv_b = (1-s)*Pag_b
Pconv_b

Pconv = Pconv_f - Pconv_b
print('''
Pconv = {:.1f} W
==============='''.format(Pconv))


I am working on the file "Chapman/Ch9-Problem_9-02.ipynb".
The first task is:
(d)
The output power is:
Can you write Python code for it?

Pout = Pconv - Prot
print('''
Pout = {:.1f} W
=============='''.format(Pout))


I am working on the file "Chapman/Ch9-Problem_9-02.ipynb".
The first task is:
(e)
The induced torque is
$$\tau_\text{ind} = \frac{P_\text{AG}}{\omega_\text{sync}}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-02.ipynb".
The first task is:
(g)
The overall efficiency is:
$$\eta = \frac{P_\text{out}}{P_\text{in}} \cdot 100\%$$
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-02.ipynb".
The first task is:
(h)
The stator power factor is:
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-02.ipynb".
The first task is:
Description
Repeat Problem 9-1 for a rotor slip of 0.025.
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-03.ipynb".
The first task is:
The air-gap power is:
Can you write Python code for it?

Pag_f = abs(I1)**2 * 0.5*Zf.real
Pag_f

Pag_b = abs(I1)**2 * 0.5*Zb.real
Pag_b

Pag = Pag_f - Pag_b
print('Pag = {:.1f} W'.format(Pag))


I am working on the file "Chapman/Ch9-Problem_9-03.ipynb".
The first task is:
The induced torque is
$$\tau_\text{ind} = \frac{P_\text{AG}}{\omega_\text{sync}}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-03.ipynb".
The first task is:
The output power is:
Can you write Python code for it?

Pout = Pconv - Prot
print('Pout = {:.1f} W'.format(Pout))


I am working on the file "Chapman/Ch9-Problem_9-03.ipynb".
The first task is:
The power converted from electrical to mechanical form is:
Can you write Python code for it?

Pconv_f = (1-s)*Pag_f
Pconv_f

Pconv_b = (1-s)*Pag_b
Pconv_b

Pconv = Pconv_f - Pconv_b
print('Pconv = {:.1f} W'.format(Pconv))


I am working on the file "Chapman/Ch9-Problem_9-04.ipynb".
The first task is:
Caclulate Zf and Zb as a function of slip
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-04.ipynb".
The first task is:
Calculate the current flowing at each slip
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-04.ipynb".
The first task is:
Calculate torque in N-m.
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-04.ipynb".
The first task is:
Get the corresponding speeds in rpm
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-04.ipynb".
The first task is:
Offset slips at 0 and 2 slightly to avoid divide by zero errors
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-04.ipynb".
The first task is:
Plot the torque-speed curve
Can you write Python code for it?

title(r'Single Phase Induction motor torque-speed characteristic')
xlabel(r'$\tau_{ind}$ [Nm]')
ylabel(r'$n_m$ [r/min]')
axis([-2000,2000,-4,4])   #set the axis range
plot(n_m, tau_ind)
grid()


I am working on the file "Chapman/Ch9-Problem_9-05.ipynb".
The first task is:
$$Z_B = \frac{(R_2/(2-s) + jX_2)(jX_M)}{R_2/(2-s) + jX_2 + jX_M}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-05.ipynb".
The first task is:
(b)
The stator power factor is:
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-05.ipynb".
The first task is:
(d)
The air-gap power is:
Can you write Python code for it?

Pag_f = abs(I1)**2*0.5*Zf.real
Pag_f

Pag_b = abs(I1)**2*0.5*Zb.real
Pag_b

Pag = Pag_f - Pag_b
print('''
Pag = {:.0f} W
============'''.format(Pag))


I am working on the file "Chapman/Ch9-Problem_9-05.ipynb".
The first task is:
(e)
The power converted from electrical to mechanical form is:
Can you write Python code for it?

Pconv_f = (1-s)*Pag_f
Pconv_f

Pconv_b = (1-s)*Pag_b
Pconv_b

Pconv = Pconv_f - Pconv_b
print('''
Pconv = {:.0f} W
=============='''.format(Pconv))


I am working on the file "Chapman/Ch9-Problem_9-05.ipynb".
The first task is:
(g)
The synchronous speed for a 6 pole 50 Hz machine is 1000 r/min, so induced torque is
$$\tau_\text{ind} = \frac{P_\text{AG}}{\omega_\text{sync}}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-05.ipynb".
The first task is:
If the slip is 0.05, find the following quantities for this motor:
(a)

Stator current

(b)

Stator power factor

(c)

Input power

(d)

$P_\text{AG}$

(e)

$P_\text{conv}$

(f)

$P_\text{out}$

(g)

$\tau_\text{ind}$

(h)

$\tau_\text{load}$

(i)

Efficiency $\eta$

SOLUTION
The equivalent circuit of the motor is shown below:
<img src="figs/FigC_9-28.jpg" width="70%">
The impedances $Z_F$ and $Z_B$ are:
$$Z_F = \frac{(R_2/s + jX_2)(jX_M)}{R_2/s + jX_2 + jX_M}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-06.ipynb".
The first task is:
$$Z_B = \frac{(R_2/(2-s) + jX_2)(jX_M)}{R_2/(2-s) + jX_2 + jX_M}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-06.ipynb".
The first task is:
$$\tau_\text{ind} = \frac{P_\text{AG}}{\omega_\text{sync}}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-06.ipynb".
The first task is:
(a)
If $\vec{V}_T = 190 \angle 0°$
$$\vec{I}_1 = \frac{\vec{V}}{R_1 + jX_1 + 0.5Z_F + 0.5Z_B}$$
Can you write Python code for it?

V_a = 190.0 # [V]
I1_a = V_a / (R1 +X1*1j + 0.5*Zf + 0.5*Zb)
I1_a_angle = arctan(I1_a.imag/I1_a.real)
print('''I1_a = {:.2f} A ∠{:.1f}°'''.format(abs(I1_a), I1_a_angle/pi*180))

Pag_f_a = abs(I1_a)**2*0.5*Zf.real
Pag_f_a

Pag_b_a = abs(I1_a)**2*0.5*Zb.real
Pag_b_a

Pag_a = Pag_f_a - Pag_b_a
Pag_a


I am working on the file "Chapman/Ch9-Problem_9-06.ipynb".
The first task is:
(b)
If $\vec{V}_T = 208 \angle 0°$
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-06.ipynb".
The first task is:
SOLUTION
The impedances $Z_F$ and $Z_B$ are:
$$Z_F = \frac{(R_2/s + jX_2)(jX_M)}{R_2/s + jX_2 + jX_M}$$
Can you write Python code for it?


I am working on the file "Chapman/Ch9-Problem_9-09.ipynb".
The first task is:
SOLUTION
From Equation (9-20),
$$n_m = \frac{1}{3p}n_\text{pulses}$$
Can you write Python code for it?


I am working on the file "Chapter 04 - Compare and Constrast.ipynb".
The first task is:
Scope
Python's scopes are a bit enigmatic.
Closure
Can you write Python code for it?

functions = []

for i in range(5):
    functions.append(lambda: i)

for f in functions:
    print(f())

%%scheme

(define functions '())

(for i in (range 5) do
    (set! functions (cons (lambda () i) functions)))

(for f in functions do
    (print (f)))


I am working on the file "Chapter 05 - Interpreting Scheme in Python.ipynb".
The first task is:
Exercise 1: Try the tokenizer on many different strings. Describe what it does in simple terms based on its input and output.
Reader
The reader will take the tokenized expression (texp) and produced grouped results.
Can you write Python code for it?

def reader(texp):
    """
    Takes the output of the tokenizer, and creates
    lists of lists of items. Numbers are represented
    as numbers.
    """
    current = None
    stack = []
    for item in texp:
        if item.isdigit():
            if current is not None:
                current.append(eval(item))
            else:
                current = eval(item)
        elif item in ["[", "("]:
            if current is not None:
                stack.append(current)
            current = []
        elif item in ["]", ")"]:
            if stack:
                stack[-1].append(current)
                current = stack.pop(-1)
            else:
                pass
        else:
            if current is not None:
                current.append(item)
            else:
                current = item
    return current

tokenizer("(this is (a) ((list))")

reader(tokenizer("(this is (a) ((list))"))


I am working on the file "Chapter 05 - Interpreting Scheme in Python.ipynb".
The first task is:
Exercise 2: Try the reader on many different tokenized strings. Describe what it does in simple terms. How does this differ from the lexer?
Parser
The final process of Step 1 is to take the output of the reader and parse it into an AST. For our first S-Calc expression, we just need to handle "(+ 1 2)". That is, we need to handle three things:

numbers - any kind of number
variables, like "+" - anything not a number
application - starts with a parenthesis
Can you write Python code for it?

## Version 1:

def parser(rexp):
    """
    Reads in a Python list of things, and returns an AST.
    """
    if isinstance(rexp, int):
        return lit_exp(rexp)
    elif isinstance(rexp, str):
        return var_exp(rexp)
    else:
        return app_exp(parser(rexp[0]), List(*map(parser, rexp[1:])))


I am working on the file "Chapter 05 - Interpreting Scheme in Python.ipynb".
The first task is:
Exercise 3: Why does the list above look like this? Is this similar to how Scheme lists exist? Explain.
Now, we can compose our AST constructor functions:
Can you write Python code for it?

def lit_exp(value):
    return List("lit-exp", value)

def var_exp(symbol):
    return List("var-exp", symbol)

def app_exp(f, args):
    return List("apply-exp", f, args)

parser(reader(tokenizer("1")))

parser(reader(tokenizer("+")))

parser(reader(tokenizer("(+ 1 2)")))


I am working on the file "Chapter 05 - Interpreting Scheme in Python.ipynb".
The first task is:
We'll be doing those three functions together quite often, so let's make a useful function:
Can you write Python code for it?

def scalc_parse(string):
    return parser(reader(tokenizer(string)))

scalc_parse("652362")


I am working on the file "Chapter 07 - Adding Variables to SCalc.ipynb".
The first task is:
So, how many variables are there?
Closures
To explore more complex variable bindings, we introduce the idea of a closure. A closure is a fuction that captures the bindings of variables.
Can you write Python code for it?

x = 1
y = 2
def make_closure():
    x = 3
    y = 4
    def f():
        print(x, y)
    return f

c = make_closure()
c()

x, y

c()

x = 5
y = 13
def make_closure():
    x = 42
    y = 911
    def func():
        global x # sees the global value
        print(x, y)
        x += 1

    return func

def make_closure():
    value = 0
    def get_next_value():
        nonlocal value
        value += 1
        return value
    return get_next_value


I am working on the file "Chapter 07 - Adding Variables to SCalc.ipynb".
The first task is:
What will happen when we call the function $f$... what will the values of x and y be after the function call?
Can you write Python code for it?


I am working on the file "Chapter 1 - Mathematical Preliminaries.ipynb".
The first task is:
Example 1.1
Can you write Python code for it?


I am working on the file "Chapter 1 - Mathematical Preliminaries.ipynb".
The first task is:
The dot function properly computes the dot product that we know and love from workshop physics:
Can you write Python code for it?

dot(rvec,cvec)

outer(cvec,rvec)

dot(cvec,rvec)  # This doesn't work, because `dot` knows what shape the vectors should be


I am working on the file "Chapter 1 - Mathematical Preliminaries.ipynb".
The first task is:
The formal definition (and to make sure we match with the book) is to take the sum and divide by the number of items in the sample:
Can you write Python code for it?


I am working on the file "Chapter 1 - Mathematical Preliminaries.ipynb".
The first task is:
The hist function has several possible arguments, we use bins=7 to match the example.
Can you write Python code for it?

# an array of the counts in each bin:
n

n/10.0*array([6,9,12,15,18,21,24])  # counts times each bin-center value

# sum of the last cell should be the mean:
sum(_)

n/10.0*array([6,9,12,15,18,21,24])**2  # counts times each bin-center value

# sum of the last cell should be the second moment:
sum(_)


I am working on the file "Chapter 1 - Mathematical Preliminaries.ipynb".
The first task is:
We can test if two quanties are equal with the == operator. Not the same as = since the = is an assignment operator. This will trip you up if you are new to programming, but you'll get over it.
Can you write Python code for it?

x.std()**2 == x.var()  # Related by a square root


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
A numpy array has two fundamental properties: it has a data type (array.dtype) and a shape (array.shape):
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
A very useful gimmick is that the indices passed, can be discontinuous, which will prove to be amazingly useful when having to select specific parts of your data:
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
Arrays aren't limited to two dimensions: just as in standard Python we would easily create a list of lists of lists etc. by inputting a nested list structure or specifying this structure as follows:
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
As you can see, only the relevant rows are included in our indexed selection. Because numpy array have multiple dimensions, we can index our data in the other dimensions too. To index entire columns, we can use the following syntax:
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
Combining existing matrices into a new matrix is also a common operation. This can be achieved via, for instance, the lines:
Can you write Python code for it?

M1 = np.zeros((2, 3))
print(M1)
M2 = np.ones((2, 3))
print(M2)
M3 = np.zeros((2, 3))
print(M3)
X = np.concatenate((M1, M2, M3))
print(X)


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
For a matrix of ones, we have the equivalent:
Can you write Python code for it?

M_ones = np.ones((8, 4))
print(M_ones)
print(M_ones.shape)


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
For such stacking operations, there exist two equivalent methods, namely hstack() for horizontal stacking and vstack() for vertical stacking:
Can you write Python code for it?

X = np.vstack((M1, M2, M3)) # equivalent to np.concatenate(..., axis=0)
print(X)
X = np.hstack((M1, M2, M3)) # equivalent to np.concatenate(..., axis=1)
print(X)


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
Here too, we can only combine matrices which have compatible shapes:
Can you write Python code for it?

M1 = np.zeros((3, 4))
M2 = np.ones((4, 4))
X = np.concatenate((M1, M2), axis=0) # does work
#X = np.concatenate((M1, M2), axis=1) # does not work


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
Here, we obtain a flat vector, instead of a vertical columns, so to speak. Of course, when we start playing with more advanced slicing strategies, we can obtain matrices too:
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
Here, we obtain a matrix which represent a 2D slice of our original matrix, namely the cells for the first rows and the second and third column.
Note that with columns too, the indices can be discontinuous, which is useful if we want to make a subselection of specific columns:
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
Indexing
Learning how to handle and manipulate numpy arrays is crucial nowadays. Just as with normal collections in Python, such as tuples, we need efficient ways to access parts of our arrays, such as a single row or column. Numpy offers good support for such based indexing, using an indexing mechanism that is very similar to what you might know from R or Matlab. Let us create a 2D matrix with random values between 0 and 1, and practice our indexing skills:
Can you write Python code for it?

X = np.random.uniform(size=(5, 4), low=0, high=1)
print(X)


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
Matrices
A single list or array of numbers is commonly refered to as a 'vector' in computing. Conventionally, vectors take lowercase (single-character) names, such as a or i above. When working with a 'list of lists', it is more common to speak about these nested collections of numbers as 'matrices' (singular: 'matrix'), which typically take uppercase names. Here goes an example of such a list of lists:
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
Note how the representation of our value collection is slightly altered, when printed (no comma's):
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
Note that the dimensionality has to work out in the latter case of course. It is impossible to turn a vector with 4 items into a row in a matrix which only has 3 columns:
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
Now that we can pass both Python lists and (immutable) tuples to the array() constructor. Make sure however to properly specify a data type if numpy might get confused when it comes to casting. Compare the following situations:
Can you write Python code for it?

# mixed:
nbs = [1, 2, 3.0]
a = np.array(nbs)
print(a.dtype)

# just ints:
nbs = [1, 2, 3]
a = np.array(nbs)
print(a.dtype)

# explicit cast:
nbs = [1.0, 2.0, 3.0]
a = np.array(nbs, dtype='int8')
print(a.dtype)


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
Of course, indexing can also be used to reset a specific part of a matrix. This works for individual elements:
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
Of course, the usual shortcuts apply:
Can you write Python code for it?

print(X[:3]) # all rows up to (and not including) row 3
print(X[-2:]) # every row after (and including) the last-but-two row


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
Please keep this behaviour in mind! Using an explicit and full copy here, might make more sense, which can be achieved using copy():
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
Specifying ranges of indices - to obtain slices of data, instead of individual data points - is also easy:
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
Such deeper matrices are often called 'tensors' nowadays, but are less common in stylometry. Just bear in mind that dtype and shape are the main properties to keep track of when dealing with Numpy's array. The exact number of dimensions can also be checked using the ndim property:
Can you write Python code for it?

print(a.ndim)  # vector
print(M2.ndim) # matrix
print(M3.ndim) # tensor


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
The final line in previous code block raises an interesting issue: the equality operator (==) here, does not simply check whether the two matrixes are simply identical. Rather, it zips together the equivalent cells in both matrices and check whether these are equal individually, i.e. in an 'element-wise' fashion. If we wanted to have check the full equivalence, we should have used:
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
The shape property captures the structure of our number collection, which is closely related to the concept of 'dimensionality'. In this case, our array only has a single 'dimension', with a 'dimensionality' of 5 - because our list contains 5 numbers:
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
This flexibility is commonly referred to as Python's 'typeless' nature: at least from the coder's perspective, Python does not seem to care about the kind of data we store inside variables. The same flexibility is offered by Python's collection-like data structures. Python's lists and tuples ('arrays'), for instance, allow us to freely mix different data types:
Can you write Python code for it?

# create a mixed list first:
arr = ['number', 5, 6.0]
print(type(arr))

# check the individual data types:
for a in arr:
    print('\t-', type(a))

# turn this into a tuple:
arr = tuple(arr)
print(type(arr))

# check the individual data types:
for a in arr:
    print('\t-', type(a))


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
This is less fast, because in reality we will select the first row, of which a full copy is returned. Only then, we will index that copy for its third element, which is of course less efficient. Finally, we should note that we can also use a 'stepping' argument when indexing, which you will probably not need very often. To select all (un)even rows from a matrix, we could use the following syntax, where our indexer always skips a beat, by specifying that steps of 2 should be used:
Can you write Python code for it?

print(X[0::2]) # uneven, starting at 1st element
print(X[1::2]) # even, starting at 2nd element


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
This matrix has a two dimensions, the shape of which can inspected via the tuple returned by array.shape:
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
To check whether everything worked well, we can do:
Can you write Python code for it?

M_trans2 = M_trans.transpose()
print(M_trans2 == M_orig)


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
To fill such a structure with another values, we can use fill():
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
Using the colon syntax (:), we indicate in fact that we want to index the 2nd column across all rows. If we only wanted to extract this column for the first two rows, we could have done:
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
What we intuitively think of as 'rows' are always the first (and in some ways principal) dimension in numpy. If we use standard indexing in numpy, we therefore index the matrix at the row-level. Naturally, we use zero-based indexing and start counting at 1, all the way up to -1:
Can you write Python code for it?


I am working on the file "Chapter 1 - Number crunching with Numpy.ipynb".
The first task is:
but also entire rows and columns:
Can you write Python code for it?


I am working on the file "Chapter 1 - Python DS Handbook.ipynb".
The first task is:
Creating Arrays from lists
Can you write Python code for it?

import numpy as np
np.array([1, 4, 2, 5, 3])

np.array([3.14, 4, 2, 3])


I am working on the file "Chapter 1 - Python DS Handbook.ipynb".
The first task is:
List can be heterogeneous list
Can you write Python code for it?

L3 = [True, '2', 3.0, 4]
[type(item) for item in L3]

tuple(L3)


I am working on the file "Chapter 1 - The Python Data Model.ipynb".
The first task is:
He talks about other dunder methods as well. In Java, Object's toString method is certainly one of the most well-known methods. In Python, this would be str and repr, two methods that are similar but have slightly different goals.
An example may make this clearer.
Can you write Python code for it?

from datetime import timedelta

class Duration:
    def __init__(self, milliseconds):
        self._duration_in_milliseconds = milliseconds

    def __repr__(self):
        # return unambiguous string that mimics the source code to construct the object back
        return "Duration({0})".format(self._duration_in_milliseconds)

    def __str__(self):
        return str(timedelta(milliseconds=self._duration_in_milliseconds))

a_billion_milliseconds = Duration(1_000_000_000)
"'{0}' is unambiguous, '{1}' is human-friendly".format(repr(a_billion_milliseconds), str(a_billion_milliseconds))


I am working on the file "Chapter 1 - Variables.ipynb".
The first task is:
"Casting" variables
Above, we have already learned that each variable as a data type: variables can be strings, floats, integers, etc. Sometimes it is necessary to convert one type into the other. Consider this:
Can you write Python code for it?


I am working on the file "Chapter 1 - Variables.ipynb".
The first task is:
Adding strings together is called 'string concatenation' or simply 'concatenation' in programming. Use the block below to find out whether you could can also use the shortcut += operator for adding an 'h' to the variable original_string. Don't forget to check the result by printing it!
Can you write Python code for it?

original_string = "blabla"
# add an 'h'...
print(original_string)


I am working on the file "Chapter 1 - Variables.ipynb".
The first task is:
Can you describe what this code did?
Can you adapt the code in this box yourself and make it print your own name?

Apart from printing words to your screen, you can also use Python to do calculations.

Use the code block below to calculate how many minutes there are in seven weeks? (Hint: multiplication is done using the * symbol in Python.)
Can you write Python code for it?


I am working on the file "Chapter 1 - Variables.ipynb".
The first task is:
Do you understand the following code block? Can you explain what is happening?
Can you write Python code for it?


I am working on the file "Chapter 1 - Variables.ipynb".
The first task is:
Ex. 3: When something is wrong with your code, Python will raise errors. Often these will be 'syntax errors' that signal that something is wrong with the form of your code (i.e. a SyntaxError like the one thrown in the previous exercice). There are also 'runtime errors' that signal that your code was in itself formally correct, but that something went wrong during the code's execution. A good example is the ZeroDivisionError. Try to make Python throw such a ZeroDivisionError!
Can you write Python code for it?


I am working on the file "Chapter 1 - Variables.ipynb".
The first task is:
Ex. 4: Write a program that assigns the result of 9.5 * 4.5 - 2.5 * 345.5 - 3.5 to a variable. Print this variable. Use round brackets to indicate 'operator precedence' and make sure that subtractions are performed before multiplications. When you convert the outcome to a string, how many characters does it count?
Can you write Python code for it?


I am working on the file "Chapter 1 - Variables.ipynb".
The first task is:
Ex. 6: Define three variables var1, var2 and var3. Calculate the average of these variables and assign it to average. Print the result in a fancy manner. Add three comments to this piece of code using three different ways.
Can you write Python code for it?


I am working on the file "Chapter 1 - Variables.ipynb".
The first task is:
Ex. 8: There is one operator (like the ones for multiplication and subtraction) that we did not mention yet, namely the modulus operator %. Could you figure by yourself what it does when you place it between two numbers (e.g. 113 % 9)? (PS: It's OK to get help online...) You don't need this operator all that often, but when you do, it comes in really handy!
Can you write Python code for it?


I am working on the file "Chapter 1 - Variables.ipynb".
The first task is:
Ex. 9: Can you use the modulus operator you just learned about to solve the following task? Write a code block that classifies a given amount of money into smaller monetary units. Set the amount variable to 11.56. You code should outputs a report listing the monetary equivalent in dollars, quarters, dimes, nickels, and pennies. Your program should report the maximum number of dollars, then the number of quarters, dimes, nickels, and pennies, in this order, to result in the minimum number of coins. Here are the steps in developing the program:
Convert the amount (11.56) into cents (1156).
  Divide the cents by 100 to find the number of dollars, but first subtract the rest using the modulus operator!
  Divide the remaining cents by 25 to find the number of quarters, but, again, first subtract the rest using the modulus operator!
  Divide the remaining cents by 10 to find the number of dimes, etc.
  Divide the remaining cents by 5 to find the number of nickels, etc.
  The remaining cents are the pennies. Now display the result for your cashier!
Can you write Python code for it?


I am working on the file "Chapter 1 - Variables.ipynb".
The first task is:
Given the following two words, can you write code that prints out the word humanities using only slicing and concatenation? (So, no quotes are allowed in your code.) Can you print out how many characters the word humanities counts?
Can you write Python code for it?


I am working on the file "Chapter 1 - Variables.ipynb".
The first task is:
If you vaguely remember your math-classes in school, this should look familiar. It is basically the same notation with the name of the variable on the left, the value on the right, and the = sign in the middle.
In the code block above, two things happen. First, we fill x with a value, in our case 2. This variable x behaves pretty much like a box on which we write an x with a thick, black marker to find it back later. We then print the contents of this box, using the print() command.

Now copy the outcome of your code calculating the number of minutes in seven weeks and assign this number to x. Run the code again.

The box metaphor for a variable goes a long way: in such a box you can put whatever value you want, e.g. the number of minutes in seven weeks. When you re-assign a variable, you remove the content of the box and  put something new in it. In Python, the term 'variable' refers to such a box, whereas the term 'value' refers to what is inside this box.
When we have stored values inside variables, we can do interesting things with these variables. You can, for instance, run the calculations in the block below to see the effect of the following five lines of code. Symbols like =, +, - and * are called 'operators' in programming: they all provide a very basic functionality such as assigning values to variables or doing multiplication and subtraction.
Can you write Python code for it?

x = 2
print(x)
print(x * x)
print(x + x)
print(x - 6)


I am working on the file "Chapter 1 - Variables.ipynb".
The first task is:
Now can you write some code that defines a variable but_last_letter and assigns to this variable the one but last letter of your name?
Can you write Python code for it?

but_last_letter = name[# insert your code here]
print(but_last_letter)