DC motor drive
A single-phase half-controlled AC-DC converter feeds a separately excited DC motor. The parameters of the DC motor are $R_a=0.4\,\Omega$, $L_a=0.5\,$H, $K_T=0.5\,$N-m/A, $J=0.001\,$kg-m$^2$, $B=0.001\,$N-m-s/rad. The rated voltage of the motor is $200\,$V DC, and the rated torque is $1\,$N-m. The grid voltage is $130\,$V, $50\,$Hz. Determine the following if the rated voltage and torque are applied to the motor.- Firing angle of the converter,
- Average motor current,
- Speed of motor,
- RMS source current,
- Source power factor,
- THD in the source current,
- Harmonic content in the electromagnetic torque.
In [1]:
from IPython.display import Image
Image(filename =r'dcmc_2_fig_1.png', width=250)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat dcmc_2_orig.in
We now replace the strings such as \$La with the values of our choice by running the python script given below. It takes an existing circuit file dcmc_2_orig.in and produces a new circuit file dcmc_2.in, after replacing \$La (etc) with values of our choice.
In [3]:
import gseim_calc as calc
import numpy as np
Vm_ac = 230.0*np.sqrt(2.0)
s_Vm_ac = ("%11.4E"%Vm_ac).strip()
s_Ra = "0.4"
s_La = "0.5"
s_k_e = "0.5"
s_J = "0.001"
s_b_damp = "0.001"
s_TL = "1"
s_alpha = "35.0" # to be changed by user
l = [
('$Vm_ac', s_Vm_ac),
('$Ra', s_Ra),
('$La', s_La),
('$k_e', s_k_e),
('$J', s_J),
('$b_damp', s_b_damp),
('$TL', s_TL),
('$alpha', s_alpha),
]
calc.replace_strings_1("dcmc_2_orig.in", "dcmc_2.in", l)
print('dcmc_2.in is ready for execution')
dcmc_2.in is ready for execution
Execute the following cell to run GSEIM on dcmc_2.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("dcmc_2.in")
os.system('run_gseim dcmc_2.in')
get_lib_elements: filename gseim_aux/xbe.aux get_lib_elements: filename gseim_aux/ebe.aux Circuit: filename = dcmc_2.in Circuit: n_xbeu_vr = 4 Circuit: n_ebeu_nd = 4 main: i_solve = 0 ssw_allocate_1 (2): n_statevar=2 main: calling solve_trns mat_ssw_1_ex: n_statevar: 2 mat_ssw_1_e0: cct.n_ebeu: 6 Transient simulation starts... i=0 i=1000 i=2000 solve_ssw_ex: ssw_iter_newton=0, rhs_ssw_norm=7.2179e+01 Transient simulation starts... i=0 i=1000 i=2000 solve_ssw_ex: ssw_iter_newton=1, rhs_ssw_norm=5.0955e+01 Transient simulation starts... i=0 i=1000 i=2000 solve_ssw_ex: ssw_iter_newton=2, rhs_ssw_norm=8.8442e-13 solve_ssw_ex: calling solve_ssw_1_ex for one more trns step Transient simulation starts... i=0 i=1000 i=2000 solve_ssw_1_ex over (after trns step for output) solve_ssw_ex ends, slv.ssw_iter_newton=2 GSEIM: Program completed.
Out[4]:
0
The circuit file (dcmc_2.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on dcmc_2.in) creates a data file called dcmc_2.dat in the same directory. We can now use the python code below to compute/plot the various quantities of interest.
In [5]:
import numpy as np
import matplotlib.pyplot as plt
import gseim_calc as calc
from setsize import set_size
f_hz = 50.0
T = 1.0/f_hz
slv = calc.slv("dcmc_2.in")
i_slv = 0
i_out = 0
filename = slv.l_filename_all[i_slv][i_out]
print('filename:', filename)
u1 = np.loadtxt(filename)
t1 = u1[:, 0]
col_v_s = slv.get_index(i_slv,i_out,"v_s")
col_i_s = slv.get_index(i_slv,i_out,"i_s")
col_tem = slv.get_index(i_slv,i_out,"tem")
col_wrm = slv.get_index(i_slv,i_out,"wrm")
col_v_dcmc = slv.get_index(i_slv,i_out,"v_dcmc")
col_i_dcmc = slv.get_index(i_slv,i_out,"i_dcmc")
i_out = 1
filename = slv.l_filename_all[i_slv][i_out]
print('filename:', filename)
u2 = np.loadtxt(filename)
t2 = u2[:, 0]
col_g1 = slv.get_index(i_slv,i_out,"g1")
col_g2 = slv.get_index(i_slv,i_out,"g2")
col_IT1 = slv.get_index(i_slv,i_out,"IT1")
col_IT2 = slv.get_index(i_slv,i_out,"IT2")
col_ID1 = slv.get_index(i_slv,i_out,"ID1")
col_ID2 = slv.get_index(i_slv,i_out,"ID2")
p_s = u1[:,col_i_s]*u1[:,col_v_s]
l_i_s = calc.avg_rms_2(t1, u1[:,col_i_s ], 0, 2.0*T, 1.0e-5*T)
l_v_s = calc.avg_rms_2(t1, u1[:,col_v_s ], 0, 2.0*T, 1.0e-5*T)
l_p_s = calc.avg_rms_2(t1, p_s , 0, 2.0*T, 1.0e-5*T)
l_i_dcmc = calc.avg_rms_2(t1, u1[:,col_i_dcmc], 0, 2.0*T, 1.0e-5*T)
l_v_dcmc = calc.avg_rms_2(t1, u1[:,col_v_dcmc], 0, 2.0*T, 1.0e-5*T)
l_tem = calc.avg_rms_2(t1, u1[:,col_tem ], 0, 2.0*T, 1.0e-5*T)
l_wrm = calc.avg_rms_2(t1, u1[:,col_wrm ], 0, 2.0*T, 1.0e-5*T)
t_i_s = np.array(l_i_s[0])
t_i_dcmc = np.array(l_i_dcmc[0])
t_v_dcmc = np.array(l_v_dcmc[0])
t_tem = np.array(l_tem[0])
t_wrm = np.array(l_wrm[0])
Pavg = l_p_s[1][0]
Irms = l_i_s[2][0]
Vrms = l_v_s[2][0]
pf_s = Pavg/(Vrms*Irms)
print('rms value of i_s:' , "%11.4E"%l_i_s [2][0])
print('average value of i_dcmc:', "%11.4E"%l_i_dcmc[1][0])
print('average value of v_dcmc:', "%11.4E"%l_v_dcmc[1][0])
print('average value of tem:' , "%11.4E"%l_tem [1][0])
print('average value of wrm:' , "%11.4E"%l_wrm [1][0])
print('source power factor:' , "%11.4E"%pf_s)
fig, ax = plt.subplots(7, sharex=False, gridspec_kw={'height_ratios': [1, 1.5, 1, 1, 1, 1, 1]})
plt.subplots_adjust(wspace=0, hspace=0.0)
set_size(6.5, 9, ax[0])
for i in range(7):
ax[i].set_xlim(left=0.0, right=2.0*T*1e3)
ax[i].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
for i in range(6):
ax[i].tick_params(labelbottom=False)
ax[0].set_ylabel(r'$V_{ac}$' , fontsize=12)
ax[1].set_ylabel(r'$g_x$' , fontsize=12)
ax[2].set_ylabel(r'$\omega$' , fontsize=12)
ax[3].set_ylabel(r'$\tau_{em}$', fontsize=12)
ax[4].set_ylabel(r'$i_s$' , fontsize=12)
ax[5].set_ylabel(r'$v_o$' , fontsize=12)
ax[6].set_ylabel(r'$i_o$' , fontsize=12)
color1 = "red"
color2 = "green"
color3 = "violet"
color4 = "tomato"
color5 = "dodgerblue"
color6 = "olive"
color7 = "blue"
color8 = "lightseagreen"
ax[0].plot(t1*1e3, u1[:,col_v_s], color=color1, linewidth=1.0, label="$V_{ac}$")
ax[1].plot(t2*1e3, (u2[:,col_g1] ), color=color2, linewidth=1.0, label="$g_1$")
ax[1].plot(t2*1e3, (u2[:,col_g2] - 1.2), color=color3, linewidth=1.0, label="$g_2$")
ax[2].plot(t1*1e3, u1[:,col_wrm ], color=color4, linewidth=1.0, label=r"$\omega$")
ax[3].plot(t1*1e3, u1[:,col_tem ], color=color5, linewidth=1.0, label=r"$\tau_{em}$")
ax[4].plot(t1*1e3, u1[:,col_i_s ], color=color6, linewidth=1.0, label=r"$i_s$")
ax[5].plot(t1*1e3, u1[:,col_v_dcmc], color=color7, linewidth=1.0, label=r"$v_o$")
ax[6].plot(t1*1e3, u1[:,col_i_dcmc], color=color8, linewidth=1.0, label=r"$i_o$")
ax[2].plot(t_wrm *1e3, l_wrm[1] , color=color4, linewidth=1.0, label=r"$\omega^{avg}$" , linestyle='--', dashes=(5,3))
ax[3].plot(t_tem *1e3, l_tem[1] , color=color5, linewidth=1.0, label=r"$\tau_{em}^{avg}$", linestyle='--', dashes=(5,3))
ax[4].plot(t_i_s *1e3, l_i_s[2] , color=color6, linewidth=1.0, label=r"$i_s^{rms}$" , linestyle='--', dashes=(5,3))
ax[5].plot(t_v_dcmc*1e3, l_v_dcmc[1], color=color7, linewidth=1.0, label=r"$v_{dcmc}^{avg}$" , linestyle='--', dashes=(5,3))
ax[6].plot(t_i_dcmc*1e3, l_i_dcmc[1], color=color8, linewidth=1.0, label=r"$i_{dcmc}^{avg}$" , linestyle='--', dashes=(5,3))
ax[1].tick_params(left = False)
ax[1].set_yticks([])
ax[6].set_xlabel('time (msec)', fontsize=12)
for i in [1, 3, 4, 5, 6]:
ax[i].legend(loc = 'lower right',frameon = True, fontsize = 10, title = None,
markerfirst = True, markerscale = 1.0, labelspacing = 0.5, columnspacing = 2.0,
prop = {'size' : 12})
#plt.tight_layout()
plt.show()
filename: dcmc_2_1.dat filename: dcmc_2_2.dat rms value of i_s: 2.5388E+00 average value of i_dcmc: 2.7483E+00 average value of v_dcmc: 1.8834E+02 average value of tem: 1.3741E+00 average value of wrm: 3.7413E+02 source power factor: 8.8691E-01
In [6]:
import numpy as np
import matplotlib.pyplot as plt
import gseim_calc as calc
from setsize import set_size
f_hz = 50.0
T = 1.0/f_hz
slv = calc.slv("dcmc_2.in")
i_slv = 0
i_out = 0
filename = slv.l_filename_all[i_slv][i_out]
print('filename:', filename)
u = np.loadtxt(filename)
t = u[:, 0]
col_i_s = slv.get_index(i_slv,i_out,"i_s")
col_tem = slv.get_index(i_slv,i_out,"tem")
# compute Fourier coeffs:
t_start = 0.0
t_end = T
n_fourier = 20
coeff_i_s, thd_i_s = calc.fourier_coeff_1C(t, u[:,col_i_s],
t_start, t_end, 1.0e-4*T, n_fourier)
print("THD (source current): ", "%5.2f"%(thd_i_s*100.0), "%")
coeff_tem, thd_tem = calc.fourier_coeff_1C(t, u[:,col_tem],
t_start, t_end, 1.0e-4*T, n_fourier)
x = np.linspace(0, n_fourier, n_fourier+1)
y_i_s = np.array(coeff_i_s)
y_tem = np.array(coeff_tem)
fig, ax = plt.subplots(2, sharex=False)
bars1 = ax[0].bar(x, y_i_s, width=0.3, color='red' , label=r"$i_s$")
bars2 = ax[1].bar(x, y_tem, width=0.3, color='blue', label=r"$\tau_{em}}$")
for k in range(2):
ax[k].set_xlabel('N', fontsize=11)
ax[k].set_xlim(left=-1, right=n_fourier)
ax[k].xaxis.set_ticks(np.arange(0, n_fourier, 2))
ax[0].set_ylabel(r'$i_s$' , fontsize=11)
ax[1].set_ylabel(r'$\tau_{em}$', fontsize=11)
plt.tight_layout()
plt.show()
filename: dcmc_2_1.dat THD (source current): 26.87 %
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: