1-phase VSI
The single phase inverter given below is operated such that the voltage across RL load is a $100\,$Hz square wave. The circuit parameters are $R=1\,\Omega$, $V_{dc}=400\,$V. The peak current through the R-L load is $98\,$A. Determine $L$.In [1]:
from IPython.display import Image
Image(filename =r'VSI_1ph_10_fig_1.png', width=300)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat VSI_1ph_10_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_10_orig.in and produces a new circuit file VSI_1ph_10.in, after replacing \$Vdc, \$L, etc. with values of our choice.
In [3]:
import gseim_calc as calc
s_Vdc = '400'
s_R = '1'
s_L = '6.5e-3' # to be changed by user
s_f_hz = "100.0"
f_hz = float(s_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_10_orig.in", "VSI_1ph_10.in", l)
print('VSI_1ph_10.in is ready for execution')
VSI_1ph_10.in is ready for execution
Execute the following cell to run GSEIM on VSI_1ph_10.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("VSI_1ph_10.in")
os.system('run_gseim VSI_1ph_10.in')
get_lib_elements: filename gseim_aux/xbe.aux get_lib_elements: filename gseim_aux/ebe.aux Circuit: filename = VSI_1ph_10.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.3939e+02 Transient simulation starts... i=0 solve_ssw_ex: ssw_iter_newton=1, rhs_ssw_norm=5.6843e-14 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_10.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on VSI_1ph_10.in) creates a data file called VSI_1ph_10.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_10.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, gridspec_kw={'height_ratios': [2, 1]})
plt.subplots_adjust(wspace=0, hspace=0.0)
set_size(5, 5, ax[0])
for k in range(2):
ax[k].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
ax[k].set_xlim(left=0.0, right=2.0*T)
ax[0].tick_params(labelbottom=False)
ax[0].plot(t, u[:,col_IR], color=color2, linewidth=1.0, label="$i_L$")
ax[0].plot(l_IR[0], l_IR[2], color=color2, linewidth=1.0, label="$i_L^{rms}$", linestyle='--', dashes=(5,3))
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[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},)
#plt.tight_layout()
plt.show()
filename: VSI_1ph_10.dat average source current: 1.8508E+01 rms source current: 8.6004E+01 rms load current: 8.6004E+01 peak load current: 1.4616E+02 power delivered to load: 7.3967E+03 zero-crossing points of load current (positive slope): 2.0327E+00 msec 1.2032E+01 msec zero-crossing points of load current (negative slope): 7.0321E+00 msec 1.7032E+01 msec
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: