1-phase VSI
The single phase inverter given below is operated such that the voltage across the RL load is a $1\,$kHz square wave. The parameter values are $V_{dc} = 100\,$V, $R = 1\,\Omega$, $L = 1\,$mH. What is the duration for which each diode conducts in a switching period?In [1]:
from IPython.display import Image
Image(filename =r'VSI_1ph_11_fig_1.png', width=300)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat VSI_1ph_11_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_11_orig.in and produces a new circuit file VSI_1ph_11.in, after replacing \$Vdc, \$L, etc. with values of our choice.
In [3]:
import gseim_calc as calc
s_Vdc = '100'
s_R = '1'
s_L = '1e-3'
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_11_orig.in", "VSI_1ph_11.in", l)
print('VSI_1ph_11.in is ready for execution')
VSI_1ph_11.in is ready for execution
Execute the following cell to run GSEIM on VSI_1ph_11.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("VSI_1ph_11.in")
os.system('run_gseim VSI_1ph_11.in')
get_lib_elements: filename gseim_aux/xbe.aux get_lib_elements: filename gseim_aux/ebe.aux Circuit: filename = VSI_1ph_11.in main: i_solve = 0 main: calling solve_trns mat_ssw_1_ex: n_statevar: 1 Transient simulation starts... i=0 i=1000 solve_ssw_ex: ssw_iter_newton=0, rhs_ssw_norm=2.1196e+01 Transient simulation starts... i=0 i=1000 solve_ssw_ex: ssw_iter_newton=1, rhs_ssw_norm=1.7053e-13 solve_ssw_ex: calling solve_ssw_1_ex for one more trns step Transient simulation starts... i=0 i=1000 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_11.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on VSI_1ph_11.in) creates a data file called VSI_1ph_11.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_11.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_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" )
i_out = 1
filename = slv.l_filename_all[i_slv][i_out]
print('filename:', filename)
u2 = np.loadtxt(filename)
t2 = u2[:, 0]
col_ID1 = slv.get_index(i_slv,i_out,"ID1")
col_ID2 = slv.get_index(i_slv,i_out,"ID2")
col_ID3 = slv.get_index(i_slv,i_out,"ID3")
col_ID4 = slv.get_index(i_slv,i_out,"ID4")
col_IS1 = slv.get_index(i_slv,i_out,"IS1")
col_IS2 = slv.get_index(i_slv,i_out,"IS2")
col_IS3 = slv.get_index(i_slv,i_out,"IS3")
col_IS4 = slv.get_index(i_slv,i_out,"IS4")
# since we have stored two cycles, we need to divide the last time point
# by 2 to get the period:
T = t1[-1]/2
l_IR = calc.avg_rms_2(t1, u1[:,col_IR ], 0.0, 2.0*T, 1.0e-4*T)
l_P_R = calc.avg_rms_2(t1, u1[:,col_P_R ], 0.0, 2.0*T, 1.0e-4*T)
l_ISrc = calc.avg_rms_2(t1, u1[:,col_ISrc], 0.0, 2.0*T, 1.0e-4*T)
l_IR_1 = calc.min_max_1(t1, u1[:,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])
# compute durations of conduction for each diode
ndiv = 5000
delt_ID1, ID1p = calc.interp_linear_1(t2, u2[:,col_ID1], ndiv)
delt_ID2, ID2p = calc.interp_linear_1(t2, u2[:,col_ID2], ndiv)
delt_ID3, ID3p = calc.interp_linear_1(t2, u2[:,col_ID3], ndiv)
delt_ID4, ID4p = calc.interp_linear_1(t2, u2[:,col_ID4], ndiv)
n_ID1 = 0
n_ID2 = 0
n_ID3 = 0
n_ID4 = 0
ID_small = 0.01
for k in range(ndiv):
if (ID1p[k] > ID_small): n_ID1 += 1
if (ID2p[k] > ID_small): n_ID2 += 1
if (ID3p[k] > ID_small): n_ID3 += 1
if (ID4p[k] > ID_small): n_ID4 += 1
print('time of conduction for D1:', "%11.4E"%(0.5*float(n_ID1)*delt_ID1), 'msec')
print('time of conduction for D2:', "%11.4E"%(0.5*float(n_ID2)*delt_ID2), 'msec')
print('time of conduction for D3:', "%11.4E"%(0.5*float(n_ID3)*delt_ID3), 'msec')
print('time of conduction for D4:', "%11.4E"%(0.5*float(n_ID4)*delt_ID4), 'msec')
color1='green'
color2='crimson'
color3='blue'
color4='olive'
fig, ax = plt.subplots(6, sharex=False)
plt.subplots_adjust(wspace=0, hspace=0.0)
set_size(5, 8, ax[0])
for k in range(6):
ax[k].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
ax[k].set_xlim(left=0.0, right=2.0*T*1e3)
for k in range(5):
ax[k].tick_params(labelbottom=False)
ax[0].set_ylabel('$i_L$' , fontsize=11)
ax[1].set_ylabel('$i_{S1}$', fontsize=11)
ax[2].set_ylabel('$i_{S2}$', fontsize=11)
ax[3].set_ylabel('$i_{D1}$', fontsize=11)
ax[4].set_ylabel('$i_{D2}$', fontsize=11)
ax[5].set_ylabel('$v_o$' , fontsize=11)
ax[0].plot(t1*1e3, u1[:,col_IR ], color=color1, linewidth=1.0, label="$i_L$")
ax[1].plot(t2*1e3, u2[:,col_IS1 ], color=color2, linewidth=1.0, label="$i_{D1}$")
ax[2].plot(t2*1e3, u2[:,col_IS2 ], color=color2, linewidth=1.0, label="$i_{D2}$")
ax[3].plot(t2*1e3, u2[:,col_ID1 ], color=color3, linewidth=1.0, label="$i_{D1}$")
ax[4].plot(t2*1e3, u2[:,col_ID2 ], color=color3, linewidth=1.0, label="$i_{D2}$")
ax[5].plot(t1*1e3, u1[:,col_v_out], color=color4, linewidth=1.0, label="$V_o$")
ax[5].set_xlabel('time (msec)', fontsize=11)
#plt.tight_layout()
plt.show()
filename: VSI_1ph_11_1.dat filename: VSI_1ph_11_2.dat average source current: 2.0711E+00 rms source current: 1.4243E+01 rms load current: 1.4243E+01 peak load current: 2.4443E+01 power delivered to load: 2.0286E+02 time of conduction for D1: 2.2040E-04 msec time of conduction for D2: 2.1880E-04 msec time of conduction for D3: 2.1880E-04 msec time of conduction for D4: 2.2040E-04 msec
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: