1-phase VSI
In the inverter circuit, $V_{S1}$ is a sinusoidal voltage of amplitude $325\,$V and frequency $50\,$Hz. The output of the inverter is a square wave with frequency of $50\,$Hz, and the DC link voltage $V_{dc}=400\,$V. The phase of $V_{S1}$ lags $V_{BD}$ of the inverter by $30^{\circ}$. The inductance is $L=10\,$mH. Determine- RMS values of fundamental, 3rd and 5th harmonic components of $i_L$
- Find the average power delivered to $V_{S1}$
- First dominant harmonic in DC link current and its RMS value
In [1]:
from IPython.display import Video, Image, HTML, display
image_path1 = "VSI_1ph_8_fig_1.png"
image_path2 = "VSI_1ph_8_fig_2.png"
HTML(f"""
<div class="row">
<img src={image_path1} style="width:30%"> </img>
<img src={image_path2} style="width:35%"> </img>
</div>
""")
Out[1]:


In [2]:
# run this cell to view the circuit file.
%pycat VSI_1ph_8_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_8_orig.in and produces a new circuit file VSI_1ph_8.in, after replacing \$Vdc, \$L, etc. with values of our choice.
In [3]:
import gseim_calc as calc
s_Vdc = '400'
s_L = '10e-3'
s_f_hz = '50.0'
s_sin = '325'
s_phi = '-30'
l = [
('$Vdc', s_Vdc),
('$L', s_L),
('$f_hz', s_f_hz),
('$A_sin', s_sin),
('$phi', s_phi)
]
calc.replace_strings_1("VSI_1ph_8_orig.in", "VSI_1ph_8.in", l)
print('VSI_1ph_8.in is ready for execution')
VSI_1ph_8.in is ready for execution
Execute the following cell to run GSEIM on VSI_1ph_8.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("VSI_1ph_8.in")
os.system('run_gseim VSI_1ph_8.in')
get_lib_elements: filename gseim_aux/xbe.aux get_lib_elements: filename gseim_aux/ebe.aux Circuit: filename = VSI_1ph_8.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=8.7584e-02 Transient simulation starts... i=0 solve_ssw_ex: ssw_iter_newton=1, rhs_ssw_norm=5.7696e-12 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_8.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on VSI_1ph_8.in) creates a data file called VSI_1ph_8.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_8.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
col_v_out = slv.get_index(i_slv,i_out,"v_out")
col_IL = slv.get_index(i_slv,i_out,"IL" )
col_Idc = slv.get_index(i_slv,i_out,"Idc" )
col_IS1 = slv.get_index(i_slv,i_out,"IS1" )
col_g1 = slv.get_index(i_slv,i_out,"g1" )
col_g2 = slv.get_index(i_slv,i_out,"g2" )
col_P_dc = slv.get_index(i_slv,i_out,"P_dc" )
col_P_S1 = slv.get_index(i_slv,i_out,"P_S1" )
# 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_IL = calc.avg_rms_2(t, u[:,col_IL ], 0.0, 2.0*T, 1.0e-4*T)
l_P_dc = calc.avg_rms_2(t, u[:,col_P_dc], 0.0, 2.0*T, 1.0e-4*T)
l_P_S1 = calc.avg_rms_2(t, u[:,col_P_S1], 0.0, 2.0*T, 1.0e-4*T)
l_Idc = calc.avg_rms_2(t, u[:,col_Idc ], 0.0, 2.0*T, 1.0e-4*T)
print('average DC source current:', "%11.4E"%l_Idc[1][0])
print('rms DC source current:', "%11.4E"%l_Idc[2][0])
print('rms load current:', "%11.4E"%l_IL[2][0])
print('power delivered by Vdc:', "%11.4E"%l_P_dc[1][0])
print('power delivered by VS1:', "%11.4E"%l_P_S1[1][0])
color1='green'
color2='crimson'
color3='goldenrod'
color4='blue'
fig, ax = plt.subplots(3, 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_IL], color=color1, linewidth=1.0, label="$i_L$")
ax[0].set_xlim(left=0.0, right=2.0*T)
ax[0].plot(l_IL[0], l_IL[2], color=color1, linewidth=1.0, label="$i_L^{rms}$", linestyle='--', dashes=(5,3))
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_Idc], color=color2, linewidth=1.0, label="$i_{dc}$")
ax[1].plot(l_Idc[0], l_Idc[2], color=color2, linewidth=1.0, label="$i_{dc}^{rms}$", linestyle='--', dashes=(5,3))
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},)
ax[2].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
ax[2].set_xlim(left=0.0, right=2.0*T)
ax[2].plot(t, u[:,col_v_out], color=color3, linewidth=1.0, label="$V_{out}$")
ax[2].set_xlabel('time (msec)', fontsize=11)
ax[2].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_8.dat average DC source current: 3.2671E+01 rms DC source current: 6.4098E+01 rms load current: 6.4098E+01 power delivered by Vdc: 1.3069E+04 power delivered by VS1: -1.3077E+04
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_8.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_IL = slv.get_index(i_slv,i_out,"IL" )
col_Idc = slv.get_index(i_slv,i_out,"Idc" )
col_IS1 = slv.get_index(i_slv,i_out,"IS1" )
col_g1 = slv.get_index(i_slv,i_out,"g1" )
col_g2 = slv.get_index(i_slv,i_out,"g2" )
col_P_dc = slv.get_index(i_slv,i_out,"P_dc" )
col_P_S1 = slv.get_index(i_slv,i_out,"P_S1" )
# since we have stored two cycles, we need to divide the last time point
# by 2 to get the period:
T = t[-1]/2
t_start = T
t_end = 2.0*T
n_fourier = 10
coeff_IL, thd_IL = calc.fourier_coeff_1C(t, u[:,col_IL],
t_start, t_end, 1.0e-8, n_fourier)
coeff_Idc, thd_Idc = calc.fourier_coeff_1C(t, u[:,col_Idc],
t_start, t_end, 1.0e-8, n_fourier)
print("THD (load current): ", "%5.2f"%(thd_IL*100.0), "%")
print("load current fundamental: RMS value: ", "%11.4E"%(coeff_IL[1]/np.sqrt(2.0)))
print("load current 3rd harmonic: RMS value: ", "%11.4E"%(coeff_IL[3]/np.sqrt(2.0)))
print("load current 5th harmonic: RMS value: ", "%11.4E"%(coeff_IL[5]/np.sqrt(2.0)))
print("DC source current fundamental: RMS value: ", "%11.4E"%(coeff_Idc[1]/np.sqrt(2.0)))
print("DC source current 2nd harmonic: RMS value: ", "%11.4E"%(coeff_Idc[2]/np.sqrt(2.0)))
print("DC source current 4th harmonic: RMS value: ", "%11.4E"%(coeff_Idc[4]/np.sqrt(2.0)))
x = np.linspace(0, n_fourier, n_fourier+1)
y_IL = np.array(coeff_IL)
y_Idc = np.array(coeff_Idc)
fig, ax = plt.subplots(2, sharex=False)
plt.subplots_adjust(wspace=0, hspace=0.0)
grid_color='#CCCCCC'
set_size(5, 4, ax[0])
delta = 2.0
x_major_ticks = np.arange(0.0, (float(n_fourier+1)), delta)
x_minor_ticks = np.arange(0.0, (float(n_fourier+1)), 1.0)
for i in range(2):
ax[i].set_xlim(left=-1.0, right=float(n_fourier))
ax[i].set_xticks(x_major_ticks)
ax[i].set_xticks(x_minor_ticks, minor=True)
ax[i].grid(visible=True, which='major', axis='x', color=grid_color, linestyle='-', zorder=0)
ax[0].set_ylabel('$i_L$',fontsize=14)
ax[1].set_ylabel('$i_{dc}$',fontsize=14)
ax[1].set_xlabel('N', fontsize=14)
bars1 = ax[0].bar(x, y_IL, width=0.3, color='red', label="$i_L$", zorder=3)
bars2 = ax[1].bar(x, y_Idc, width=0.3, color='blue', label="$i_{dc}$", zorder=3)
plt.tight_layout()
plt.show()
filename: VSI_1ph_8.dat THD (load current): 22.20 % load current fundamental: RMS value: 6.2574E+01 load current 3rd harmonic: RMS value: 1.2739E+01 load current 5th harmonic: RMS value: 4.5878E+00 DC source current fundamental: RMS value: 2.4969E-01 DC source current 2nd harmonic: RMS value: 3.9138E+01 DC source current 4th harmonic: RMS value: 2.3603E+01
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: