1-phase VSI
In the full-bridge circuit shown below, the switches are controlled such that the voltage across the $RL$ load is a square wave of frequency $50\,$Hz. The other parameters are $R=10\,\Omega$, $L= 0.1\,$H and $V_{dc}=400\,$V.- Plot the current through DC source and determine its average value.
- Determine the peak load current.
- Determine the RMS value of the fundamental component of the load current.
- What is the interval between the zero crossings of load voltage and load current?
- Determine the power delivered to the load.
- Determine the THD of the voltage across the $RL$ load.
- Estimate the THD of the load current.
In [1]:
from IPython.display import Image
Image(filename =r'VSI_1ph_2_fig_1.png', width=300)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat VSI_1ph_2_orig.in
We now replace the strings such as \$Vdc, \$L, with the values of our choice by running the python script given below. It takes an existing circuit file VSI_1ph_2_orig.in and produces a new circuit file VSI_1ph_2.in, after replacing \$Vdc, \$L, etc. with values of our choice.
In [3]:
import gseim_calc as calc
s_Vdc = '400'
s_R = '10'
s_L = '0.1'
f_hz = 50.0
s_f_hz = "%11.4E"%(f_hz)
T = 1/f_hz
s_Tby2 = "%11.4E"%(T/2)
l = [
('$Vdc', s_Vdc),
('$R', s_R),
('$L', s_L),
('$f_hz', s_f_hz),
('$Tby2', s_Tby2)
]
calc.replace_strings_1("VSI_1ph_2_orig.in", "VSI_1ph_2.in", l)
print('VSI_1ph_2.in is ready for execution')
VSI_1ph_2.in is ready for execution
Execute the following cell to run GSEIM on VSI_1ph_2.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("VSI_1ph_2.in")
os.system('run_gseim VSI_1ph_2.in')
get_lib_elements: filename gseim_aux/xbe.aux get_lib_elements: filename gseim_aux/ebe.aux Circuit: filename = VSI_1ph_2.in main: i_solve = 0 main: calling solve_trns mat_ssw_1_ex: n_statevar: 1 Transient simulation starts... i=0 solve_ssw_ex: ssw_iter_newton=0, rhs_ssw_norm=1.8104e+01 Transient simulation starts... i=0 solve_ssw_ex: ssw_iter_newton=1, rhs_ssw_norm=3.5527e-15 solve_ssw_ex: calling solve_ssw_1_ex for one more trns step Transient simulation starts... i=0 solve_ssw_1_ex over (after trns step for output) solve_ssw_ex ends, slv.ssw_iter_newton=1 GSEIM: Program completed.
Out[4]:
0
The circuit file (VSI_1ph_2.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on VSI_1ph_2.in) creates a data file called VSI_1ph_2.datin 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
slv = calc.slv("VSI_1ph_2.in")
i_slv = 0
i_out = 0
filename = slv.l_filename_all[i_slv][i_out]
print('filename:', filename)
u = np.loadtxt(filename)
t1 = u[:, 0]
t = 1e3*t1 # convert time to msec
col_v_out = slv.get_index(i_slv,i_out,"v_out")
col_IR = slv.get_index(i_slv,i_out,"IR" )
col_ISrc = slv.get_index(i_slv,i_out,"ISrc" )
col_P_R = slv.get_index(i_slv,i_out,"P_R" )
col_g1 = slv.get_index(i_slv,i_out,"g1" )
col_g2 = slv.get_index(i_slv,i_out,"g2" )
# since we have stored two cycles, we need to divide the last time point
# by 2 to get the period:
T = t[-1]/2
l_IR = calc.avg_rms_2(t, u[:,col_IR ], 0.0, 2.0*T, 1.0e-4*T)
l_P_R = calc.avg_rms_2(t, u[:,col_P_R ], 0.0, 2.0*T, 1.0e-4*T)
l_ISrc = calc.avg_rms_2(t, u[:,col_ISrc], 0.0, 2.0*T, 1.0e-4*T)
l_IR_1 = calc.min_max_1(t, u[:,col_IR], 0.0, 2.0*T)
print('average source current:', "%11.4E"%l_ISrc[1][0])
print('rms source current:', "%11.4E"%l_ISrc[2][0])
print('rms load current:', "%11.4E"%l_IR[2][0])
print('peak load current:', "%11.4E"%l_IR_1[1])
print('power delivered to load:', "%11.4E"%l_P_R[1][0])
l_cross_1_IR, l_cross_2_IR = calc.cross_over_points_1(t, u[:,col_IR], 0.0, 2.0*T, 0.0)
print('zero-crossing points of load current (positive slope):')
for t1 in l_cross_1_IR:
print(" ", "%11.4E"%t1, "msec")
print('zero-crossing points of load current (negative slope):')
for t1 in l_cross_2_IR:
print(" ", "%11.4E"%t1, "msec")
color1='green'
color2='crimson'
color3='goldenrod'
color4='blue'
fig, ax = plt.subplots(2, sharex=False)
plt.subplots_adjust(wspace=0, hspace=0.0)
set_size(5, 6, ax[0])
ax[0].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
ax[0].plot(t, u[:,col_IR], color=color1, linewidth=1.0, label="$i_L$")
ax[0].set_xlim(left=0.0, right=2.0*T)
ax[0].plot(l_IR[0], l_IR[2], color=color1, linewidth=1.0, label="$i_L^{rms}$", linestyle='--', dashes=(5,3))
ax[0].plot(t, u[:,col_ISrc], color=color2, linewidth=1.0, label="$i_{dc}$")
ax[0].plot(l_IR[0], l_ISrc[1], color=color2, linewidth=1.0, label="$i_{dc}^{avg}$", linestyle='--', dashes=(5,3))
ax[0].set_xlabel('time (msec)', fontsize=11)
ax[0].legend(loc = 'lower right',frameon = True, fontsize = 10, title = None,
markerfirst = True, markerscale = 1.0, labelspacing = 0.5, columnspacing = 2.0,
prop = {'size' : 12},)
ax[1].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
ax[1].set_xlim(left=0.0, right=2.0*T)
ax[1].plot(t, u[:,col_v_out], color=color1, linewidth=1.0, label="$V_o$")
ax[1].set_xlabel('time (msec)', fontsize=11)
ax[1].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: VSI_1ph_2.dat average source current: 3.0184E+00 rms source current: 1.0986E+01 rms load current: 1.0986E+01 peak load current: 1.8446E+01 power delivered to load: 1.2068E+03 zero-crossing points of load current (positive slope): 3.8015E+00 msec 2.3801E+01 msec zero-crossing points of load current (negative slope): 1.3801E+01 msec 3.3802E+01 msec
In [6]:
import numpy as np
import matplotlib.pyplot as plt
import gseim_calc as calc
from setsize import set_size
slv = calc.slv("VSI_1ph_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_v_out = slv.get_index(i_slv,i_out,"v_out")
col_IR = slv.get_index(i_slv,i_out,"IR" )
col_ISrc = slv.get_index(i_slv,i_out,"ISrc" )
col_P_R = slv.get_index(i_slv,i_out,"P_R" )
col_g1 = slv.get_index(i_slv,i_out,"g1" )
col_g2 = slv.get_index(i_slv,i_out,"g2" )
# since we have stored two cycles, we need to divide the last time point
# by 2 to get the period:
T = t[-1]/2
# compute Fourier coeffs:
t_start = 0.0
t_end = T
n_fourier_IR = 20
coeff_IR, thd_IR = calc.fourier_coeff_1C(t, u[:,col_IR],
t_start, t_end, 1.0e-4*T, n_fourier_IR)
print('fourier coefficients (load current):')
for i, c in enumerate(coeff_IR):
print(" %3d %11.4E"% (i, c))
print("THD (load current): ", "%5.2f"%(thd_IR*100.0), "%")
print("load current fundamental: RMS value: ", "%11.4E"%(coeff_IR[1]/np.sqrt(2.0)))
n_fourier_v_out = 20
coeff_v_out, thd_v_out = calc.fourier_coeff_1C(t, u[:,col_v_out],
t_start, t_end, 1.0e-4*T, n_fourier_v_out)
print('fourier coefficients (load voltage):')
for i, c in enumerate(coeff_v_out):
print(" %3d %11.4E"% (i, c))
print("THD (load voltage): ", "%5.2f"%(thd_v_out*100.0), "%")
x_IR = np.linspace(0, n_fourier_IR, n_fourier_IR+1)
x_v_out = np.linspace(0, n_fourier_v_out, n_fourier_v_out+1)
y_IR = np.array(coeff_IR)
y_v_out = np.array(coeff_v_out)
fig, ax = plt.subplots(2, sharex=False)
bars1 = ax[0].bar(x_IR, y_IR, width=0.3, color='red', label="$i_{load}$")
bars2 = ax[1].bar(x_v_out, y_v_out, width=0.3, color='blue', label="$V_{out}$")
ax[0].set_xlabel('N', fontsize=11)
ax[0].set_ylabel('$i_{load}$', fontsize=11)
ax[0].set_xlim(left=0, right=n_fourier_IR)
ax[0].xaxis.set_ticks(np.arange(0, n_fourier_IR, 2))
ax[0].legend(loc = 'upper right',frameon = True, fontsize = 10, title = None,
markerfirst = True, markerscale = 1.0, labelspacing = 0.5, columnspacing = 2.0,
prop = {'size' : 12},)
ax[1].set_xlabel('N', fontsize=11)
ax[1].set_ylabel('$v_{out}$', fontsize=11)
ax[1].set_xlim(left=0, right=n_fourier_v_out)
ax[1].xaxis.set_ticks(np.arange(0, n_fourier_v_out, 2))
ax[1].legend(loc = 'upper 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: VSI_1ph_2.dat fourier coefficients (load current): 0 6.5506E-04 1 1.5412E+01 2 9.3382E-04 3 1.7862E+00 4 9.2519E-04 5 6.4496E-01 6 9.2352E-04 7 3.2910E-01 8 9.2306E-04 9 1.9895E-01 10 9.2273E-04 11 1.3303E-01 12 9.2247E-04 13 9.5106E-02 14 9.2248E-04 15 7.1316E-02 16 9.2248E-04 17 5.5421E-02 18 9.2231E-04 19 4.4280E-02 20 9.2221E-04 THD (load current): 12.67 % load current fundamental: RMS value: 1.0898E+01 fourier coefficients (load voltage): 0 1.5750E-07 1 5.0928E+02 2 9.3401E-06 3 1.6973E+02 4 1.9064E-05 5 1.0181E+02 6 2.7974E-05 7 7.2683E+01 8 3.8084E-05 9 5.6494E+01 10 4.6681E-05 11 4.6184E+01 12 5.7033E-05 13 3.9040E+01 14 6.5474E-05 15 3.3796E+01 16 7.5890E-05 17 2.9780E+01 18 8.4363E-05 19 2.6606E+01 20 9.4654E-05 THD (load voltage): 48.34 %
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: