1-phase VSI (PWM)

The figure below shows a full-bridge uni-polar PWM voltage source inverter supplying an $RL$ load with $R=10\,\Omega$, $L=10\,$mH, and $V_{dc}=400\,$V. The switches S1 and S2 are switched in a complementary fashion with sinusoidal pulse width modulation technique with a modulating voltage $V_m^a(t)=0.8\,\sin (100\,\pi\,t)$. Similarly, switches S3 and S4 are switched in a complementary fashion with sinusoidal pulse width modulation technique with a modulating voltage $V_m^b(t)=-0.8\,\sin (100\,\pi\,t)$. The carrier frequency is $2\,$kHz. Determine
  1. RMS values of the fundamental components of the load voltage and load current
  2. average current through the DC source
  3. RMS values of the two lowest-order harmonics of the DC source current (50 Hz, 100 Hz)
  4. average power delivered to the load
  5. dominant harmonics present in the load voltage and current
In [1]:
from IPython.display import Image
Image(filename =r'VSI_1ph_7_fig_1.png', width=550)
Out[1]:
No description has been provided for this image
In [2]:
# run this cell to view the circuit file.
%pycat VSI_1ph_7_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_7_orig.in and produces a new circuit file VSI_1ph_7.in, after replacing \$Vdc, \$L, etc. with values of our choice.

In [3]:
import gseim_calc as calc
s_Vdc = "400"
s_L = "10e-3"
s_R = "10"
s_f_carrier = "2e3"
s_M = "0.8"
s_dt_min = "1e-6"
s_dt_nrml = "5e-6"

f_sin = 50.0
s_f_sin = ("%11.4E"%(f_sin)).strip()

T = 1/f_sin
s_2T = ("%11.4E"%(2.0*T)).strip()

l = [
  ('$Vdc', s_Vdc),
  ('$L', s_L),
  ('$R', s_R),
  ('$f_carrier', s_f_carrier),
  ('$f_sin', s_f_sin),
  ('$2T', s_2T),
  ('$M', s_M),
  ('$dt_min', s_dt_min),
  ('$dt_nrml', s_dt_nrml)
]
calc.replace_strings_1("VSI_1ph_7_orig.in", "VSI_1ph_7.in", l)
print('VSI_1ph_7.in is ready for execution')
VSI_1ph_7.in is ready for execution
Execute the following cell to run GSEIM on VSI_1ph_7.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("VSI_1ph_7.in")
os.system('run_gseim VSI_1ph_7.in')
Circuit: filename = VSI_1ph_7.in
main: calling solve_trns
Transient simulation starts...
i=0
i=1000
i=2000
i=3000
i=4000
i=5000
i=6000
i=7000
i=8000
GSEIM: Program completed.
Out[4]:
0

The circuit file (VSI_1ph_7.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on VSI_1ph_7.in) creates two data files called VSI_1ph_7.dat and VSI_1ph_7_1.dat in the same directory. We can now use the python code below to compute/plot the various quantities of interest.

In [5]:
calc.print_rms(
   infile='VSI_1ph_7.in', i_slv=0, i_out=0,
   var_name="v_out", t_start=20e-3, t_end=40e-3,
   s_format="%11.4E", s1="rms load voltage:", s2="V")

calc.print_avg(
   infile='VSI_1ph_7.in', i_slv=0, i_out=0,
   var_name="ISrc", t_start=20e-3, t_end=40e-3,
   s_format="%11.4E", s1="average source current:", s2="Amp")

calc.print_avg(
   infile='VSI_1ph_7.in', i_slv=0, i_out=0,
   var_name="P_R", t_start=20e-3, t_end=40e-3,
   s_format="%11.4E", s1="average power delivered to load:", s2="W")

n_plots = 4
l_n_curves = [3, 1, 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 = 1
plot_multi.plot_all[0].l_plots[0].var_name = "s1"
plot_multi.plot_all[0].l_plots[0].plot_type = "X-time"
plot_multi.plot_all[0].l_plots[0].label = "s1"
plot_multi.plot_all[0].l_plots[0].color = "blue"
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[1].i_slv = 0
plot_multi.plot_all[0].l_plots[1].i_out = 1
plot_multi.plot_all[0].l_plots[1].var_name = "s2"
plot_multi.plot_all[0].l_plots[1].plot_type = "X-time"
plot_multi.plot_all[0].l_plots[1].label = "s2"
plot_multi.plot_all[0].l_plots[1].color = "blue"
plot_multi.plot_all[0].l_plots[1].linewidth = 1.0
plot_multi.plot_all[0].l_plots[1].linestyle = "dashed"
plot_multi.plot_all[0].l_plots[1].line_tuple = (3,2)

plot_multi.plot_all[0].l_plots[2].i_slv = 0
plot_multi.plot_all[0].l_plots[2].i_out = 1
plot_multi.plot_all[0].l_plots[2].var_name = "t"
plot_multi.plot_all[0].l_plots[2].plot_type = "X-time"
plot_multi.plot_all[0].l_plots[2].label = "t"
plot_multi.plot_all[0].l_plots[2].color = "cornflowerblue"
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[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 = "green"
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[2].l_plots[0].i_slv = 0
plot_multi.plot_all[2].l_plots[0].i_out = 0
plot_multi.plot_all[2].l_plots[0].var_name = "ISrc"
plot_multi.plot_all[2].l_plots[0].plot_type = "X-time"
plot_multi.plot_all[2].l_plots[0].color = "goldenrod"
plot_multi.plot_all[2].l_plots[0].linewidth = 1.0
plot_multi.plot_all[2].l_plots[0].linestyle = "solid"

plot_multi.plot_all[3].l_plots[0].i_slv = 0
plot_multi.plot_all[3].l_plots[0].i_out = 0
plot_multi.plot_all[3].l_plots[0].var_name = "IR"
plot_multi.plot_all[3].l_plots[0].plot_type = "X-time"
plot_multi.plot_all[3].l_plots[0].color = "crimson"
plot_multi.plot_all[3].l_plots[0].linewidth = 1.0
plot_multi.plot_all[3].l_plots[0].linestyle = "solid"

plot_multi.plot_all[0].y_label = ""
plot_multi.plot_all[0].legend_flag = True

plot_multi.plot_all[1].y_label = "$V_{out}$"
plot_multi.plot_all[1].legend_flag = False

plot_multi.plot_all[2].y_label = "$i_{dc}$"
plot_multi.plot_all[2].legend_flag = False

plot_multi.plot_all[3].y_label = "$i_L$"
plot_multi.plot_all[3].legend_flag = False

calc.plot_multi_time(
   infile='VSI_1ph_7.in',
   t_mult=1e3,
   x_size=7.0,
   y_size=7.0,
   x_label='time (msec)',
   label_font_size=14,
   legend_fontsize=10,
   t_start=0.0,
   t_end=20e-3,
   t_offset=0.0,
   plot_multi=plot_multi)
rms load voltage:  2.8547E+02 V
average source current:  1.1660E+01 Amp
average power delivered to load:  4.6598E+03 W
filename: VSI_1ph_7_1.dat
filename: VSI_1ph_7.dat
No description has been provided for this image
In [6]:
import numpy as np

n_plots = 3
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 = True
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 = True
plot_multi.plot_all[1].y_label = "$V_{out}$"

plot_multi.plot_all[2].i_slv = 0
plot_multi.plot_all[2].i_out = 0
plot_multi.plot_all[2].var_name = "ISrc"
plot_multi.plot_all[2].color = "green"
plot_multi.plot_all[2].compute_thd = False
plot_multi.plot_all[2].y_label = "$i_{dc}$"

calc.plot_multi_fourier(infile='VSI_1ph_7.in',
    x_size=7.0, y_size=6., x_div_minor=1, x_div_major=10,
    label_font_size=12, bar_width=0.3,
    n_fourier=100, t_start=20e-3, t_end=40e-3, fourier_multi=plot_multi)

coeff_ISrc, thd_ISrc = calc.get_fourier_coeff(infile='VSI_1ph_7.in', i_slv=0, i_out=0,
  var_name='ISrc', n_fourier=100, t_start=20e-3, t_end=40e-3)
print("DC source current 2nd harmonic: RMS value: ", "%11.4E"%(coeff_ISrc[2]/np.sqrt(2.0)))
filename: VSI_1ph_7.dat
IR fundamental (RMS value): 2.1579E+01
THD in IR:  2.64 %
v_out fundamental (RMS value): 2.2626E+02
THD in v_out: 76.94 %
ISrc fundamental (RMS value): 3.1036E-03
No description has been provided for this image
filename: VSI_1ph_7.dat
DC source current 2nd harmonic: RMS value:   8.6323E+00

This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.

In [ ]: