1-phase VSI
In the half bridge inverter shown below, the switches S1 and S2 are switched alternatively at a $50\,\%$ duty cycle with a switching frequency of $1\,$kHz. The other parameters are $R=20\,\Omega$, $L=10\,$mH and $V_{dc}=200\,$V.- Plot the current through the 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_1_fig_1.png', width=200)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat VSI_1ph_1_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_1_orig.in and produces a new circuit file VSI_1ph_1.in, after replacing \$Vdc, \$L, etc. with values of our choice.
In [3]:
import gseim_calc as calc
s_Vdc = '200'
s_R = '20'
s_L = '10m'
f_hz = 1.0e3
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_1_orig.in", "VSI_1ph_1.in", l)
print('VSI_1ph_1.in is ready for execution')
VSI_1ph_1.in is ready for execution
Execute the following cell to run GSEIM on VSI_1ph_1.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("VSI_1ph_1.in")
os.system('run_gseim VSI_1ph_1.in')
Circuit: filename = VSI_1ph_1.in main: calling solve_sss solve_sss starting: sss_n_st: 1 solve_sss_ex: sss_iter_newton=0, rhs_sss_norm=4.5144e+00, sss_period_1_compute=2.0000e-03 solve_sss_ex: sss_iter_newton=1, rhs_sss_norm=3.4639e-14, sss_period_1_compute=2.0000e-03 solve_sss_ex: calling sss_solve_trns_ex for one more trns step Transient simulation starts... i=0 i=1000 GSEIM: Program completed.
Out[4]:
0
The circuit file (VSI_1ph_1.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on VSI_1ph_1.in) creates a data file called VSI_1ph_1.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_1.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 = t1*1e3 # convert time to msec
v_out = slv.get_array_double(i_slv,i_out,"v_out",u)
IR = slv.get_array_double(i_slv,i_out,"IR" ,u)
ISrc1 = slv.get_array_double(i_slv,i_out,"ISrc1",u)
ISrc2 = slv.get_array_double(i_slv,i_out,"ISrc2",u)
P_R = slv.get_array_double(i_slv,i_out,"P_R" ,u)
g1 = slv.get_array_double(i_slv,i_out,"g1" ,u)
g2 = slv.get_array_double(i_slv,i_out,"g2" ,u)
# 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_3a(t, IR , 0.0, 2.0*T, 1.0e-4*T)
l_P_R = calc.avg_rms_3a(t, P_R , 0.0, 2.0*T, 1.0e-4*T)
l_ISrc1 = calc.avg_rms_3a(t, ISrc1, 0.0, 2.0*T, 1.0e-4*T)
l_IR_1 = calc.min_max_1(t, IR, 0.0, 2.0*T)
print('average source current:' , "%11.4E"%l_ISrc1[0])
print('rms source current:' , "%11.4E"%l_ISrc1[1])
print('rms load current:' , "%11.4E"%l_IR[1])
print('peak load current:' , "%11.4E"%l_IR_1[1])
print('power delivered to load:', "%11.4E"%l_P_R[0])
l_cross_1_IR, l_cross_2_IR = calc.cross_over_points_1(t, 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)
print('zero-crossing points of load current (negative slope):')
for t1 in l_cross_2_IR:
print(" ", "%11.4E"%t1)
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, IR, color=color1, linewidth=1.0, label="$i_L$")
ax[0].set_xlim(left=0.0, right=2.0*T)
ax[0].axhline(y=l_IR[1], color=color1, linewidth=1.0, label="$i_L^{rms}$", linestyle='--', dashes=(5,3))
ax[0].plot(t, ISrc1, color=color2, linewidth=1.0, label="$i_1$")
ax[0].axhline(y=l_ISrc1[0], color=color2, linewidth=1.0, label="$i_1^{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, 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_1.dat
average source current: 3.8148E-01
rms source current: 1.9436E+00
rms load current: 2.7476E+00
peak load current: 4.6133E+00
power delivered to load: 1.5099E+02
zero-crossing points of load current (positive slope):
1.8957E-01
1.1896E+00
zero-crossing points of load current (negative slope):
6.8957E-01
1.6896E+00
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_1.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]
v_out = slv.get_array_double(i_slv,i_out,"v_out",u)
IR = slv.get_array_double(i_slv,i_out,"IR" ,u)
ISrc1 = slv.get_array_double(i_slv,i_out,"ISrc1",u)
ISrc2 = slv.get_array_double(i_slv,i_out,"ISrc2",u)
P_R = slv.get_array_double(i_slv,i_out,"P_R" ,u)
g1 = slv.get_array_double(i_slv,i_out,"g1" ,u)
g2 = slv.get_array_double(i_slv,i_out,"g2" ,u)
# 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, 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, 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_1.dat
fourier coefficients (load current):
0 6.3207E-06
1 3.8550E+00
2 1.8360E-06
3 4.4698E-01
4 8.5322E-07
5 1.6153E-01
6 8.3377E-07
7 8.2534E-02
8 1.3224E-06
9 4.9989E-02
10 2.1110E-06
11 3.3514E-02
12 3.0401E-06
13 2.4046E-02
14 4.2005E-06
15 1.8114E-02
16 5.4861E-06
17 1.4159E-02
18 6.9502E-06
19 1.1397E-02
20 8.5378E-06
THD (load current): 12.65 %
load current fundamental: RMS value: 2.7259E+00
fourier coefficients (load voltage):
0 5.1020E-02
1 2.5465E+02
2 1.0205E-01
3 8.4874E+01
4 1.0207E-01
5 5.0916E+01
6 1.0211E-01
7 3.6359E+01
8 1.0216E-01
9 2.8270E+01
10 1.0222E-01
11 2.3120E+01
12 1.0230E-01
13 1.9553E+01
14 1.0239E-01
15 1.6936E+01
16 1.0250E-01
17 1.4933E+01
18 1.0262E-01
19 1.3351E+01
20 1.0276E-01
THD (load voltage): 48.31 %
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: