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$, $L=10\,$mH, $V_{dc}=100\,$V. What is the average current through the dc voltage source?In [1]:
from IPython.display import Image
Image(filename =r'VSI_1ph_14_fig_1.png', width=300)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat VSI_1ph_14_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_14_orig.in and produces a new circuit file VSI_1ph_14.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 = '10e-3'
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_14_orig.in", "VSI_1ph_14.in", l)
print('VSI_1ph_14.in is ready for execution')
VSI_1ph_14.in is ready for execution
Execute the following cell to run GSEIM on VSI_1ph_14.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("VSI_1ph_14.in")
os.system('run_gseim VSI_1ph_14.in')
get_lib_elements: filename gseim_aux/xbe.aux get_lib_elements: filename gseim_aux/ebe.aux Circuit: filename = VSI_1ph_14.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=2.1117e+01 Transient simulation starts... i=0 solve_ssw_ex: ssw_iter_newton=1, rhs_ssw_norm=9.2371e-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_14.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on VSI_1ph_14.in) creates a data file called VSI_1ph_14.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_14.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])
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_ISrc], color=color2, linewidth=1.0, label="$i_{src}$")
ax[0].plot(l_ISrc[0], l_ISrc[1], color=color2, linewidth=1.0, label="$i_{src}^{avg}$", 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_14.dat average source current: 2.0259E+00 rms source current: 1.4223E+01 rms load current: 1.4223E+01 peak load current: 2.4429E+01 power delivered to load: 2.0230E+02
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: