Bi-directional voltage source converter
A half bridge converter is connected to an AC voltage source as shown below. The converter is operated using sinusoidal pulse width modulation. 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)=0.75\,\sin (100\,\pi\,t)$. If $f$ denotes the AC source freqency, which frequency components are present in the DC link current $i_{dc}$?- $f$, $2\,f$, and switching frequency components
- only switching frequency components
- $2\,f$ and switching frequency components
- $f$ and switching frequency components
In [1]:
from IPython.display import Image
Image(filename =r'VSC_bi_9_fig_1.png', width=500)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat VSC_bi_9_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_9_orig.in and produces a new circuit file VSC_bi_9.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.75"
s_phi = "0.0"
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_9_orig.in", "VSC_bi_9.in", l)
print('VSC_bi_9.in is ready for execution')
VSC_bi_9.in is ready for execution
Execute the following cell to run GSEIM on VSC_bi_9.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("VSC_bi_9.in")
os.system('run_gseim VSC_bi_9.in')
get_lib_elements: filename gseim_aux/xbe.aux get_lib_elements: filename gseim_aux/ebe.aux Circuit: filename = VSC_bi_9.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=3.2238e-03 Transient simulation starts... i=0 i=10000 i=20000 i=30000 i=40000 solve_ssw_ex: ssw_iter_newton=1, rhs_ssw_norm=1.2434e-14 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_9.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on VSC_bi_9.in) creates a data file called VSC_bi_9.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_9.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_v_VS3 = slv.get_index(i_slv,i_out,"v_VS3")
col_i_VS3 = slv.get_index(i_slv,i_out,"i_VS3")
col_i_VS1 = slv.get_index(i_slv,i_out,"i_VS1")
# 0.1e-3 is the clock period:
l1 = calc.avg_rms_1(t, u[:,col_i_VS3], 0.1e-3)
fig, ax = plt.subplots(3, sharex=False, gridspec_kw={'height_ratios': [1, 1, 1]})
plt.subplots_adjust(wspace=0, hspace=0.0)
set_size(6.5, 4.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_{ac}$', fontsize=12)
ax[1].set_ylabel(r'$i_{ac}$', fontsize=12)
ax[2].set_ylabel(r'$i_{dc}$', fontsize=12)
ax[0].tick_params(labelbottom=False)
ax[1].tick_params(labelbottom=False)
color1 = "blue"
color2 = "green"
color3 = "crimson"
color4 = "red"
color5 = "palegreen"
color4 = "crimson"
ax[0].plot(t*1e3, u[:,col_v_VS3], color=color1, linewidth=1.0, label="$v_{ac}$")
ax[1].plot(t*1e3, u[:,col_i_VS3], color=color5, linewidth=1.0, label="$i_{ac}$")
ax[2].plot(t*1e3, u[:,col_i_VS1], color=color3, linewidth=1.0, label="$i_{dc}$")
ax[1].plot(np.array(l1[0])*1e3, l1[1], color=color2, linewidth=1.0, label="$i_{ac}^{avg}$")
ax[2].set_xlabel('time (msec)', fontsize=12)
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},)
#plt.tight_layout()
plt.show()
filename: VSC_bi_9.dat
In [6]:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import (MultipleLocator, AutoMinorLocator)
import gseim_calc as calc
from setsize import set_size
f_hz = 50.0
T = 1.0/f_hz
slv = calc.slv("VSC_bi_9.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_i_VS1 = slv.get_index(i_slv,i_out,"i_VS1")
# compute Fourier coeffs:
t_start = T
t_end = 2.0*T
n_fourier = 250
coeff_i_VS1, thd_i_VS1 = calc.fourier_coeff_1C(t, u[:,col_i_VS1],
t_start, t_end, 1.0e-8, n_fourier)
x = np.linspace(0, n_fourier, n_fourier+1)
y_i_VS1 = np.array(coeff_i_VS1)
fig, ax = plt.subplots()
plt.subplots_adjust(wspace=0, hspace=0.0)
set_size(5.5, 2.5, ax)
plt.grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
delta = 50.0
x_major_ticks = np.arange(0.0, (float(n_fourier+1)), delta)
x_minor_ticks = np.arange(0.0, (float(n_fourier+1)), delta/5)
ax.set_xlim(left=-10.0, right=float(n_fourier))
ax.set_xticks(x_major_ticks)
ax.set_xticks(x_minor_ticks, minor=True)
ax.grid(visible=True, which='major', axis='x', color='#CCCCCC', linestyle='-', zorder=0)
ax.set_ylabel('$i_{dc}$',fontsize=14)
ax.set_xlabel('N', fontsize=14)
bars1 = ax.bar(x, y_i_VS1, width=0.7, color='red', label="$i_{dc}$", zorder=3)
plt.tight_layout()
plt.show()
filename: VSC_bi_9.dat
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: