1-phase VSI
The single-phase inverter is operated such that the voltage across the RL load is as shown below. The parameters are $V_{dc}=400\,$V, $R=5\,\Omega$, $L=1\,$mH. Find $\alpha$ in degrees for which the fundamental RMS voltage across the load is $220\,$V.In [1]:
from IPython.display import Image
Image(filename =r'VSI_1ph_13_fig_1.png', width=700)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat VSI_1ph_13_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_13_orig.in and produces a new circuit file VSI_1ph_13.in, after replacing \$Vdc, \$L, etc. with values of our choice.
In [3]:
import gseim_calc as calc
s_Vdc = '400'
s_R = '5'
s_L = '1e-3'
alpha = 65.0 # to be changed by user
f_hz = 50.0
s_f_hz = ("%11.4E"%(f_hz)).strip()
d = 180.0 - 2.0*alpha
T = 1/f_hz
t0_1 = (alpha/360)*T
t0_2 = t0_1 + (d/360)*T
s_t0_1 = ("%11.4E"%(t0_1)).strip()
s_t0_2 = ("%11.4E"%(t0_2)).strip()
l = [
('$Vdc', s_Vdc),
('$R', s_R),
('$L', s_L),
('$f_hz', s_f_hz),
('$t0_1', s_t0_1),
('$t0_2', s_t0_2)
]
calc.replace_strings_1("VSI_1ph_13_orig.in", "VSI_1ph_13.in", l)
print('VSI_1ph_13.in is ready for execution')
VSI_1ph_13.in is ready for execution
Execute the following cell to run GSEIM on VSI_1ph_13.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("VSI_1ph_13.in")
os.system('run_gseim VSI_1ph_13.in')
Circuit: filename = VSI_1ph_13.in main: calling solve_sss solve_sss starting: sss_n_st: 1 solve_sss_ex: sss_iter_newton=0, rhs_sss_norm=5.5346e-06, sss_period_1_compute=4.0000e-02 solve_sss_ex: sss_iter_newton=1, rhs_sss_norm=0.0000e+00, sss_period_1_compute=4.0000e-02 solve_sss_ex: calling sss_solve_trns_ex for one more trns step Transient simulation starts... i=0 i=1000 GSEIM: Program completed.
Out[4]:
0
The circuit file (VSI_1ph_13.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on VSI_1ph_13.in) creates a data file called VSI_1ph_13.datin the same directory. We can now use the python code below to compute/plot the various quantities of interest.
In [5]:
calc.print_avg(
infile='VSI_1ph_13.in', i_slv=0, i_out=0,
var_name="ISrc", t_start=0.0, t_end=40.0e-3,
s_format="%11.4E", s1="average source current:", s2="Amp")
calc.print_rms(
infile='VSI_1ph_13.in', i_slv=0, i_out=0,
var_name="ISrc", t_start=0.0, t_end=40.0e-3,
s_format="%11.4E", s1="rms source current:", s2="Amp")
calc.print_rms(
infile='VSI_1ph_13.in', i_slv=0, i_out=0,
var_name="IR", t_start=0.0, t_end=40.0e-3,
s_format="%11.4E", s1="rms load current:", s2="Amp")
calc.print_rms(
infile='VSI_1ph_13.in', i_slv=0, i_out=0,
var_name="v_out", t_start=0.0, t_end=40.0e-3,
s_format="%11.4E", s1="rms load voltage:", s2="V")
calc.print_max(
infile='VSI_1ph_13.in', i_slv=0, i_out=0,
var_name="IR", t_start=0.0, t_end=40.0e-3,
s_format="%11.4E", s1="peak load current:", s2="Amp")
calc.print_avg(
infile='VSI_1ph_13.in', i_slv=0, i_out=0,
var_name="P_R", t_start=0.0, t_end=40.0e-3,
s_format="%11.4E", s1="power delivered to load:", s2="W")
n_plots = 2
l_n_curves = [1, 1]
plot_multi = calc.gseim_plot_multi(n_plots, l_n_curves)
plot_multi.plot_all[0].l_plots[0].i_slv = 0
plot_multi.plot_all[0].l_plots[0].i_out = 0
plot_multi.plot_all[0].l_plots[0].var_name = "IR"
plot_multi.plot_all[0].l_plots[0].plot_type = "X-time"
plot_multi.plot_all[0].l_plots[0].color = "green"
plot_multi.plot_all[0].l_plots[0].linewidth = 1.0
plot_multi.plot_all[0].l_plots[0].linestyle = "solid"
plot_multi.plot_all[1].l_plots[0].i_slv = 0
plot_multi.plot_all[1].l_plots[0].i_out = 0
plot_multi.plot_all[1].l_plots[0].var_name = "v_out"
plot_multi.plot_all[1].l_plots[0].plot_type = "X-time"
plot_multi.plot_all[1].l_plots[0].color = "red"
plot_multi.plot_all[1].l_plots[0].linewidth = 1.0
plot_multi.plot_all[1].l_plots[0].linestyle = "solid"
plot_multi.plot_all[0].y_label = "$I_L$"
plot_multi.plot_all[0].legend_flag = False
plot_multi.plot_all[1].y_label = "$V_{out}$"
plot_multi.plot_all[1].legend_flag = False
calc.plot_multi_time(
infile='VSI_1ph_13.in',
t_mult=1e3,
x_size=5.0,
y_size=5.0,
x_label='time (msec)',
label_font_size=11,
legend_fontsize=10,
t_start=0.0,
t_end=40e-3,
t_offset=0.0,
plot_multi=plot_multi)
average source current: 2.0508E+01 Amp rms source current: 3.9632E+01 Amp rms load current: 4.0473E+01 Amp rms load voltage: 2.1081E+02 V peak load current: 7.9997E+01 Amp power delivered to load: 8.1901E+03 W filename: VSI_1ph_13.dat
In [6]:
n_plots = 2
l_n_curves = [4, 1]
plot_multi = calc.gseim_plot_multi(n_plots, l_n_curves)
plot_multi.plot_all[0].l_plots[0].i_slv = 0
plot_multi.plot_all[0].l_plots[0].i_out = 0
plot_multi.plot_all[0].l_plots[0].var_name = "g1"
plot_multi.plot_all[0].l_plots[0].plot_type = "X-time"
plot_multi.plot_all[0].l_plots[0].label = "$g_1$"
plot_multi.plot_all[0].l_plots[0].color = "tomato"
plot_multi.plot_all[0].l_plots[0].linewidth = 1.0
plot_multi.plot_all[0].l_plots[0].linestyle = "solid"
plot_multi.plot_all[0].l_plots[0].y_offset = 0.0
plot_multi.plot_all[0].l_plots[1].i_slv = 0
plot_multi.plot_all[0].l_plots[1].i_out = 0
plot_multi.plot_all[0].l_plots[1].var_name = "g2"
plot_multi.plot_all[0].l_plots[1].plot_type = "X-time"
plot_multi.plot_all[0].l_plots[1].label = "$g_2$"
plot_multi.plot_all[0].l_plots[1].color = "dodgerblue"
plot_multi.plot_all[0].l_plots[1].linewidth = 1.0
plot_multi.plot_all[0].l_plots[1].linestyle = "solid"
plot_multi.plot_all[0].l_plots[1].y_offset = -1.5
plot_multi.plot_all[0].l_plots[2].i_slv = 0
plot_multi.plot_all[0].l_plots[2].i_out = 0
plot_multi.plot_all[0].l_plots[2].var_name = "g3"
plot_multi.plot_all[0].l_plots[2].plot_type = "X-time"
plot_multi.plot_all[0].l_plots[2].label = "$g_3$"
plot_multi.plot_all[0].l_plots[2].color = "olive"
plot_multi.plot_all[0].l_plots[2].linewidth = 1.0
plot_multi.plot_all[0].l_plots[2].linestyle = "solid"
plot_multi.plot_all[0].l_plots[2].y_offset = -3.0
plot_multi.plot_all[0].l_plots[3].i_slv = 0
plot_multi.plot_all[0].l_plots[3].i_out = 0
plot_multi.plot_all[0].l_plots[3].var_name = "g4"
plot_multi.plot_all[0].l_plots[3].plot_type = "X-time"
plot_multi.plot_all[0].l_plots[3].label = "$g_4$"
plot_multi.plot_all[0].l_plots[3].color = "blue"
plot_multi.plot_all[0].l_plots[3].linewidth = 1.0
plot_multi.plot_all[0].l_plots[3].linestyle = "solid"
plot_multi.plot_all[0].l_plots[3].y_offset = -4.5
plot_multi.plot_all[1].l_plots[0].i_slv = 0
plot_multi.plot_all[1].l_plots[0].i_out = 0
plot_multi.plot_all[1].l_plots[0].var_name = "v_out"
plot_multi.plot_all[1].l_plots[0].plot_type = "X-time"
plot_multi.plot_all[1].l_plots[0].color = "red"
plot_multi.plot_all[1].l_plots[0].linewidth = 1.0
plot_multi.plot_all[1].l_plots[0].linestyle = "solid"
plot_multi.plot_all[0].y_label = r'$g_x$'
plot_multi.plot_all[0].legend_flag = True
plot_multi.plot_all[0].rel_height = 1.5
plot_multi.plot_all[0].legend_position = 'lower right'
plot_multi.plot_all[0].show_ytics = False
plot_multi.plot_all[1].y_label = r'$V_{out}$'
plot_multi.plot_all[1].legend_flag = False
calc.plot_multi_time(
infile='VSI_1ph_13.in',
t_mult=1e3,
x_size=5.0,
y_size=5.5,
x_label='time (msec)',
label_font_size=11,
legend_fontsize=10,
t_start=0.0,
t_end=40.0e-3,
t_offset=0.0,
plot_multi=plot_multi)
filename: VSI_1ph_13.dat
In [7]:
import numpy as np
n_plots = 2
plot_multi = calc.gseim_fourier_multi(n_plots)
plot_multi.plot_all[0].i_slv = 0
plot_multi.plot_all[0].i_out = 0
plot_multi.plot_all[0].var_name = "IR"
plot_multi.plot_all[0].color = "red"
plot_multi.plot_all[0].compute_thd = "yes"
plot_multi.plot_all[0].y_label = "$i_{load}$"
plot_multi.plot_all[1].i_slv = 0
plot_multi.plot_all[1].i_out = 0
plot_multi.plot_all[1].var_name = "v_out"
plot_multi.plot_all[1].color = "blue"
plot_multi.plot_all[1].compute_thd = "no"
plot_multi.plot_all[1].y_label = "$V_{out}$"
calc.plot_multi_fourier(infile='VSI_1ph_13.in',
x_size=6.0, y_size=4.0, x_div_minor=1, x_div_major=2,
label_font_size=12, bar_width=0.3,
n_fourier=20, t_start=0.0, t_end=20e-3, fourier_multi=plot_multi)
print('First few harmonics:')
coeff_IR, thd_IR = calc.get_fourier_coeff(infile='VSI_1ph_13.in', i_slv=0, i_out=0,
var_name='IR', n_fourier=20, t_start=0.0, t_end=20.0e-3)
print("load current fundamental: RMS value: ", "%11.4E"%(coeff_IR[1]/np.sqrt(2.0)))
print("load current 3rd harmonic: RMS value: ", "%11.4E"%(coeff_IR[3]/np.sqrt(2.0)))
print("load current 5th harmonic: RMS value: ", "%11.4E"%(coeff_IR[5]/np.sqrt(2.0)))
print()
coeff_v_out, thd_v_out = calc.get_fourier_coeff(infile='VSI_1ph_13.in', i_slv=0, i_out=0,
var_name='v_out', n_fourier=20, t_start=0.0, t_end=20.0e-3)
print("load voltage fundamental: RMS value: ", "%11.4E"%(coeff_v_out[1]/np.sqrt(2.0)))
print("load voltage 3rd harmonic: RMS value: ", "%11.4E"%(coeff_v_out[3]/np.sqrt(2.0)))
print("load voltage 5th harmonic: RMS value: ", "%11.4E"%(coeff_v_out[5]/np.sqrt(2.0)))
filename: VSI_1ph_13.dat IR fundamental (RMS value): 3.0367E+01 THD in IR: 88.11 % v_out fundamental (RMS value): 1.5219E+02 THD in v_out: 95.85 %
First few harmonics: filename: VSI_1ph_13.dat load current fundamental: RMS value: 3.0367E+01 load current 3rd harmonic: RMS value: 2.2712E+01 load current 5th harmonic: RMS value: 1.1159E+01 filename: VSI_1ph_13.dat load voltage fundamental: RMS value: 1.5219E+02 load voltage 3rd harmonic: RMS value: 1.1594E+02 load voltage 5th harmonic: RMS value: 5.8979E+01
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: