Phasors
A 50 kVA, 2400/240 V, 50 Hz distribution transformer (see the equivalent circuit shown below) has a leakage impedance of $0.72 + j\,0.92\,\Omega$ in the high-voltage winding and $0.007 + j\,0.009\,\Omega$ in the low-voltage winding. At the rated voltage and frequency, $R_c'$ and $X_m'$ (i.e., $R_c$ and $X_m$ viewed from the LV side) are $308.4\,\Omega$ and $44.63\,\Omega$, respectively. The transformer delivers $40\,kW$ at $240\,V$ at a lagging power factor of 0.8 to a load $R_L + j\,X_L$ on the LV side.- Determine $R_L$ and $X_L$.
- Determine ${\bf{V}}_p$ (magnitude and phase) such that the load voltage is $240\angle 0$ V (rms).
- Draw the phasor diagram showing the relationship between ${\bf{V}}_p$, ${\bf{V}}_m$, and ${\bf{V}}_s'$.
In [1]:
from IPython.display import Image
Image(filename =r'phasor_12_fig_1.png', width=500)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat phasor_12_orig.in
We now replace strings such as \$Rp with the value of our choice by running the python script given below. It takes an existing circuit file phasor_12_orig.in and produces a new circuit file phasor_12.in, after replacing \$Rp etc with the values of our choice.
In [3]:
import gseim_calc as calc
import numpy as np
Vs_rms = 2500.0 # to be changed by user
s_Vs_phi = "0.5" # (degrees) to be changed by user
RLs = 0.5 # to be changed by user
XLs = 0.2 # to be changed by user
n = 10.0 # turns ratio
n2 = float(n*n)
Rp = 0.72
Xp = 0.92
Rs = 0.007
Xs = 0.009
Xms = 44.63
Rcs = 308.4
Vs = Vs_rms*np.sqrt(2.0)
Rsp = Rs*n2
Xsp = Xs*n2
Xm = Xms*n2
Rc = Rcs*n2
RLp = RLs*n2
XLp = XLs*n2
f = 50.0
omg = 2.0*np.pi*f
Lp = Xp/omg
Lsp = Xsp/omg
Lm = Xm/omg
LLp = XLp/omg
s_Vs_mag = ("%11.4E"%(Vs)).strip()
s_Rp = ("%11.4E"%(Rp )).strip()
s_Rc = ("%11.4E"%(Rc )).strip()
s_Rsp = ("%11.4E"%(Rsp)).strip()
s_Lp = ("%11.4E"%(Lp )).strip()
s_Lm = ("%11.4E"%(Lm )).strip()
s_Lsp = ("%11.4E"%(Lsp)).strip()
s_RLp = ("%11.4E"%(RLp)).strip()
s_LLp = ("%11.4E"%(LLp)).strip()
l = [
('$Vs_mag', s_Vs_mag),
('$Vs_phi', s_Vs_phi),
('$Rp', s_Rp),
('$Rc', s_Rc),
('$Rsp', s_Rsp),
('$Lp', s_Lp),
('$Lm', s_Lm),
('$Lsp', s_Lsp),
('$RLp', s_RLp),
('$LLp', s_LLp),
]
calc.replace_strings_1("phasor_12_orig.in", "phasor_12.in", l)
print('phasor_12.in is ready for execution')
phasor_12.in is ready for execution
Execute the following cell to run GSEIM on phasor_5.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("phasor_12.in")
os.system('run_gseim phasor_12.in')
Circuit: filename = phasor_12.in main: i_solve = 0 GSEIM: Program completed.
Out[4]:
0
The circuit file (phasor_12.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on phasor_12.in) creates data files phasor_12_1.dat and phasor_12_2.dat in the same directory. We can now use the python code below to compute and display the quantities of interest.
In [5]:
import numpy as np
import gseim_calc as calc
import matplotlib.pyplot as plt
from matplotlib.ticker import (MultipleLocator, AutoMinorLocator)
from setsize import set_size
import cmath
rad_to_deg = 180.0/np.pi
slv = calc.slv("phasor_12.in")
i_slv = 0
i_out = 0
filename = slv.l_filename_all[i_slv][i_out]
print('filename:', filename)
u = np.loadtxt(filename)
Ic = slv.get_scalar_complex_1(i_slv, i_out, "Ic", u)
Im = slv.get_scalar_complex_1(i_slv, i_out, "Im", u)
Ip = slv.get_scalar_complex_1(i_slv, i_out, "Ip", u)
Isp = slv.get_scalar_complex_1(i_slv, i_out, "Isp", u)
i_slv = 0
i_out = 1
filename = slv.l_filename_all[i_slv][i_out]
print('filename:', filename)
u = np.loadtxt(filename)
Vm = slv.get_scalar_complex_1(i_slv, i_out, "Vm", u)
Vp = slv.get_scalar_complex_1(i_slv, i_out, "Vp", u)
Vsp = slv.get_scalar_complex_1(i_slv, i_out, "Vsp", u)
# compute power delivered to load and p.f.
phi_Isp = cmath.phase(Isp)
phi_Vsp = cmath.phase(Vsp)
phi = phi_Vsp - phi_Isp
print('phi_Vsp:', "%11.4E"%(phi_Vsp*180.0/np.pi), 'deg')
print('phi_Isp:', "%11.4E"%(phi_Isp*180.0/np.pi), 'deg')
pf = np.cos(phi)
PL = 0.5*abs(Vsp)*abs(Isp)*pf
print('PL:', "%11.4E"%PL)
print('power factor:', "%7.4f"%pf)
print('voltage phasors in rectangular form:')
s_format = "%7.2f"
calc.print_complex_rect('Vm', Vm, s_format)
calc.print_complex_rect('Vp', Vp, s_format)
calc.print_complex_rect('Vsp', Vsp, s_format)
print('voltage phasors in polar form:')
calc.print_complex_polar('Vm', Vm, s_format)
calc.print_complex_polar('Vp', Vp, s_format)
calc.print_complex_polar('Vsp', Vsp, s_format)
print('current phasors in rectangular form:')
calc.print_complex_rect('Ic' , Ic, s_format)
calc.print_complex_rect('Im' , Im, s_format)
calc.print_complex_rect('Ip' , Ip, s_format)
calc.print_complex_rect('Isp', Isp, s_format)
print('current phasors in polar form:')
calc.print_complex_polar('Ic' , Ic, s_format)
calc.print_complex_polar('Im' , Im, s_format)
calc.print_complex_polar('Ip' , Ip, s_format)
calc.print_complex_polar('Isp', Isp, s_format)
# convert to rms and pu
Vscale = 2400.0
sqrt2 = np.sqrt(2.0)
Vm_pu = Vm/(sqrt2*Vscale)
Vp_pu = Vp/(sqrt2*Vscale)
Vsp_pu = Vsp/(sqrt2*Vscale)
VZs_pu = Isp*(Rsp + Xsp*(complex(0.0,1.0)))/(sqrt2*Vscale)
VZp_pu = Ip *(Rp + Xp *(complex(0.0,1.0)))/(sqrt2*Vscale)
l_colors = ["blue", "red", "green", "grey", "dodgerblue",
"tomato", "brown", "gold", "magenta"]
l1 = []
l1_labels = []
color_Vm_pu = calc.phasor_append_1a(l1, l1_labels, Vm_pu, "$V_m$ (p.u.)", l_colors)
color_Vp_pu = calc.phasor_append_1a(l1, l1_labels, Vp_pu, "$V_p$ (p.u.)", l_colors)
color_Vsp_pu = calc.phasor_append_1a(l1, l1_labels, Vsp_pu, "$V_s'$ (p.u.)", l_colors)
color_VZs_pu = calc.phasor_append_1a(l1, l1_labels, VZs_pu, "$V_{Zs}'$ (p.u.)", l_colors)
color_VZp_pu = calc.phasor_append_1a(l1, l1_labels, VZp_pu, "$V_{Zp}'$ (p.u.)", l_colors)
theta_deg = 20.0
length_arrow = calc.phasor_3(l1, 0.02)
l1_arrow = calc.phasor_2(l1, theta_deg, length_arrow, 0.2)
l2 = []
l2_colors = []
calc.phasor_append_2(l2, l2_colors, Vsp_pu, (Vsp_pu + VZs_pu), color_VZs_pu)
calc.phasor_append_2(l2, l2_colors, (Vsp_pu + VZs_pu), (Vsp_pu + VZs_pu + VZp_pu), color_VZp_pu)
l2_arrow = calc.phasor_2(l2, theta_deg, length_arrow, 0.2)
fig, ax = plt.subplots()
ax.set_aspect('equal', adjustable='box')
ax.grid()
for i, l_dummy in enumerate(l1_arrow):
for k, t in enumerate(l_dummy):
if (k == 0):
ax.plot(t[0],t[1], color=l_colors[i], label=l1_labels[i])
else:
ax.plot(t[0],t[1], color=l_colors[i])
for i, l_dummy in enumerate(l2_arrow):
for k, t in enumerate(l_dummy):
ax.plot(t[0],t[1], color=l2_colors[i], linestyle='--', dashes=(4, 2))
calc.revise_axis_limits_1(ax, 3.0)
ax.legend(loc='center left', fontsize=11, bbox_to_anchor=(1.05, 0.5))
plt.xlabel('Re (V) p.u.', fontsize=11)
plt.ylabel('Im (V) p.u.', fontsize=11)
plt.show()
filename: phasor_12_1.dat filename: phasor_12_2.dat phi_Vsp: -6.8495E-01 deg phi_Isp: -2.2486E+01 deg PL: 1.0011E+05 power factor: 0.9285 voltage phasors in rectangular form: Vm: (3470.21, -5.06) Vp: (3535.37, 30.85) Vsp: (3407.50, -40.74) voltage phasors in polar form: Vm: magnitude: 3470.21, angle: -0.08 deg Vp: magnitude: 3535.50, angle: 0.50 deg Vsp: magnitude: 3407.74, angle: -0.68 deg current phasors in rectangular form: Ic: ( 0.11, -0.00) Im: ( -0.00, -0.78) Ip: ( 58.58, -24.98) Isp: ( 58.47, -24.20) current phasors in polar form: Ic: magnitude: 0.11, angle: -0.08 deg Im: magnitude: 0.78, angle: -90.08 deg Ip: magnitude: 63.68, angle: -23.09 deg Isp: magnitude: 63.28, angle: -22.49 deg
In [6]:
y_max = -100.0
y_min = 100.0
y_min = min(y_min, Vm_pu.imag)
y_min = min(y_min, Vp_pu.imag)
y_min = min(y_min, Vsp_pu.imag)
y_min = min(y_min, VZs_pu.imag)
y_min = min(y_min, VZp_pu.imag)
y_max = max(y_max, Vm_pu.imag)
y_max = max(y_max, Vp_pu.imag)
y_max = max(y_max, Vsp_pu.imag)
y_max = max(y_max, VZs_pu.imag)
y_max = max(y_max, VZp_pu.imag)
x_min = -0.1
x_max = 1.1
x_scale = x_max - x_min
y_scale = y_max - y_min
l1_arrow = calc.phasor_2A(l1 , theta_deg, length_arrow, 0.2, x_scale, y_scale)
l2_arrow = calc.phasor_2A(l2 , theta_deg, length_arrow, 0.2, x_scale, y_scale)
fig, ax = plt.subplots()
ax.grid()
ax.set_xlim(x_min, x_max)
ax.set_ylim(y_min, y_max)
for i, l_dummy in enumerate(l1_arrow):
for k, t in enumerate(l_dummy):
if (k == 0):
ax.plot(t[0],t[1], color=l_colors[i], label=l1_labels[i])
else:
ax.plot(t[0],t[1], color=l_colors[i])
for i, l_dummy in enumerate(l2_arrow):
for k, t in enumerate(l_dummy):
ax.plot(t[0],t[1], color=l2_colors[i], linestyle='--', dashes=(4, 2))
ax.legend(loc='center left', fontsize=11, bbox_to_anchor=(1.05, 0.5))
plt.xlabel('Re (V) p.u.', fontsize=11)
plt.ylabel('Im (V) p.u.', fontsize=11)
plt.show()
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: