1-phase VSI
In the inverter circuit, $V_{S1}$ is a square wave source with amplitude $300\,$V. The phase of $V_{S1}$ is the same as that of the output voltage $V_{BC}$ of the inverter. The output of the inverter is a square wave with frequency of $50\,$Hz, and the DC link voltage $V_{DC}=400\,$V. The other parameters are $R=2\,\Omega$ and $L=20\,$mH.- Plot the currents $i_{dc}$ and $i_L$.
- Find the average power delivered to $V_{S1}$.
- Find the power delivered to the load.
- Find the average power transferred from the DC voltage source.
- Find the peak values of $i_{dc}$ and $i_L$.
In [1]:
from IPython.display import Image
Image(filename =r'VSI_1ph_3_fig_1.png', width=400)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat VSI_1ph_3_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_3_orig.in and produces a new circuit file VSI_1ph_3.in, after replacing \$Vdc, \$L, etc. with values of our choice.
In [3]:
import gseim_calc as calc
s_Vdc = '400'
s_R = '2'
s_L = '20e-3'
f_hz = 50.0
s_f_hz = ("%11.4E"%(f_hz)).strip()
T = 1/f_hz
s_Tby2 = ("%11.4E"%(T/2)).strip()
VS1_peak = 300.0
s_L1 = ("%11.4E"%VS1_peak).strip()
s_L2 = ("%11.4E"%(-VS1_peak)).strip()
l = [
('$Vdc', s_Vdc),
('$R', s_R),
('$L', s_L),
('$f_hz', s_f_hz),
('$Tby2', s_Tby2),
('$VS1_L1', s_L1),
('$VS1_L2', s_L2)
]
calc.replace_strings_1("VSI_1ph_3_orig.in", "VSI_1ph_3.in", l)
print('VSI_1ph_3.in is ready for execution')
VSI_1ph_3.in is ready for execution
Execute the following cell to run GSEIM on VSI_1ph_3.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("VSI_1ph_3.in")
os.system('run_gseim VSI_1ph_3.in')
get_lib_elements: filename gseim_aux/xbe.aux get_lib_elements: filename gseim_aux/ebe.aux Circuit: filename = VSI_1ph_3.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.2519e+01 Transient simulation starts... i=0 solve_ssw_ex: ssw_iter_newton=1, rhs_ssw_norm=2.1316e-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_3.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on VSI_1ph_3.in) creates a data file called VSI_1ph_3.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_3.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_Idc = slv.get_index(i_slv,i_out,"Idc" )
col_P_R = slv.get_index(i_slv,i_out,"P_R" )
col_P_dc = slv.get_index(i_slv,i_out,"P_dc" )
col_P_S1 = slv.get_index(i_slv,i_out,"P_S1" )
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_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)
l_IR_1 = calc.min_max_1(t, u[:,col_IR ], 0.0, 2.0*T)
l_Idc_1 = calc.min_max_1(t, u[:,col_Idc], 0.0, 2.0*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_IR[2][0])
print('peak load current:', "%11.4E"%l_IR_1[1])
print('power absorbed by load:', "%11.4E"%l_P_R[1][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])
print('peak Idc:', l_Idc_1[1])
print('peak IL:', l_IR_1[1])
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_IR], color=color1, linewidth=1.0, label="$i_L$")
ax[0].set_xlim(left=0.0, right=2.0*T)
ax[0].plot(l_IR[0], l_IR[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_3.dat average DC source current: 3.8004E+00 rms DC source current: 1.3732E+01 rms load current: 1.3732E+01 peak load current: 2.3085E+01 power absorbed by load: 3.7713E+02 power delivered by Vdc: 1.5202E+03 power delivered by VS1: -1.1409E+03 peak Idc: 23.08492 peak IL: 23.08476
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: