Bi-directional voltage source converter

The half-bridge bi-directional voltage source converter given below is used to pump $1\,$kW of power at unity power factor to the AC voltage source. The switches are operated using the pulse width modulation technique. The modulation voltage is $m(t)$, and the triangular carrier voltage is $v_c(t)$. The switch S1 is turned on when $m(t) > v_c(t)$, and the switch S2 is turned on otherwise. The parameter values are $L=10\,$mH, $f_c=10\,$kHz, and $V_{dc}=400\,$V. The AC source voltage is $v_s(t) = 230\sqrt{2}\,\sin (100\,\pi\,t)$, and the modulation voltage is $m(t)=M\,\sin (100\,\pi\,t + \phi)$. Find $M$ and $\phi$ (in degrees).
In [1]:
from IPython.display import Image
Image(filename =r'VSC_bi_1_fig_1.png', width=500)
Out[1]:
No description has been provided for this image
In [2]:
# run this cell to view the circuit file.
%pycat VSC_bi_1_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 VSC_bi_1_orig.in and produces a new circuit file VSC_bi_1.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_f_carrier = "10e3"
s_M = "0.5" # to be changed by user
s_phi = "1.0" # to be changed by user
s_dt_min = "0.01e-6"
s_dt_nrml = "1e-6"

l = [
  ('$Vdc', s_Vdc),
  ('$L', s_L),
  ('$f_carrier', s_f_carrier),
  ('$M', s_M),
  ('$phi', s_phi),
  ('$dt_min', s_dt_min),
  ('$dt_nrml', s_dt_nrml)
]
calc.replace_strings_1("VSC_bi_1_orig.in", "VSC_bi_1.in", l)
print('VSC_bi_1.in is ready for execution')
VSC_bi_1.in is ready for execution
Execute the following cell to run GSEIM on VSC_bi_1.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("VSC_bi_1.in")
os.system('run_gseim VSC_bi_1.in')
get_lib_elements: filename gseim_aux/xbe.aux
get_lib_elements: filename gseim_aux/ebe.aux
Circuit: filename = VSC_bi_1.in
main: i_solve = 0
main: calling solve_trns
mat_ssw_1_ex: n_statevar: 1
Transient simulation starts...
i=0
i=10000
i=20000
i=30000
i=40000
solve_ssw_ex: ssw_iter_newton=0, rhs_ssw_norm=1.5957e-02
Transient simulation starts...
i=0
i=10000
i=20000
i=30000
i=40000
solve_ssw_ex: ssw_iter_newton=1, rhs_ssw_norm=6.9633e-13
solve_ssw_ex: calling solve_ssw_1_ex for one more trns step
Transient simulation starts...
i=0
i=10000
i=20000
i=30000
i=40000
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 (VSC_bi_1.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on VSC_bi_1.in) creates a data file called VSC_bi_1.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

f_hz = 50.0
T = 1.0/f_hz

slv = calc.slv("VSC_bi_1.in")

i_slv = 0
i_out = 0
filename = slv.l_filename_all[i_slv][i_out]
print('filename:', filename)
u = np.loadtxt(filename)
t = u[:, 0]

col_P_VS3 = slv.get_index(i_slv,i_out,"P_VS3")
col_v_VS3 = slv.get_index(i_slv,i_out,"v_VS3")
col_i_VS3 = slv.get_index(i_slv,i_out,"i_VS3")

l_v_VS3 = calc.avg_rms_2(t, u[:,col_v_VS3], 0, 2.0*T, 1.0e-5*T)
t_v_VS3 = np.array(l_v_VS3[0])
l_i_VS3 = calc.avg_rms_2(t, u[:,col_i_VS3], 0, 2.0*T, 1.0e-5*T)
t_i_VS3 = np.array(l_i_VS3[0])
l_P_VS3 = calc.avg_rms_2(t, u[:,col_P_VS3], 0, 2.0*T, 1.0e-5*T)
t_P_VS3 = np.array(l_P_VS3[0])

print('AC source rms voltage:'  , "%11.4E"%l_v_VS3[2][0])
print('AC source rms current:'  , "%11.4E"%l_i_VS3[2][0])
print('AC source average power:', "%11.4E"%l_P_VS3[1][0])

Irms = l_i_VS3[2][0]
Vrms = l_v_VS3[2][0]
pf = l_P_VS3[1][0]/(Vrms*Irms)

print('power factor (AC source):', "%6.3f"%pf)

fig, ax = plt.subplots(3, sharex=False)
plt.subplots_adjust(wspace=0, hspace=0.0)

set_size(6.5, 5, ax[0])

for i in range(3):
    ax[i].set_xlim(left=0.0, right=2.0*T*1e3)
    ax[i].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)

ax[0].set_ylabel(r'$v_s$', fontsize=12)
ax[1].set_ylabel(r'$i_s$', fontsize=12)
ax[2].set_ylabel(r'$p_s$', fontsize=12)

ax[0].tick_params(labelbottom=False)

color1 = "blue"
color2 = "tomato"
color3 = "olive"

ax[0].plot(t*1e3, u[:,col_v_VS3], color=color1, linewidth=1.0, label="$v_s$")
ax[1].plot(t*1e3, u[:,col_i_VS3], color=color2, linewidth=1.0, label="$i_s$")
ax[2].plot(t*1e3, u[:,col_P_VS3], color=color3, linewidth=1.0, label="$p_s$")

ax[2].set_xlabel('time (msec)', fontsize=12)

for i in range(3):
    ax[i].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: VSC_bi_1.dat
AC source rms voltage:  2.3002E+02
AC source rms current:  2.8224E+01
AC source average power: -1.7785E+02
power factor (AC source): -0.027
No description has been provided for this image

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

In [ ]: