Bi-directional converter
A single-phase bi-directional voltage source conveter is connected to an AC voltage source through an impedance $Z = R + j\,\omega\,L$ with $R=10\,\Omega$ and $L=0.1\,$H. The waveform of the voltage source $v_s$ is a square wave from $300\,$V to $-300\,$V. The phase and frequency of $v_s$ is the same as that of the output voltage $v_{BD}$ of the converter. The DC link voltage $V_{DC}=400\,$V. If the inverter frequency is $100\,$Hz, what is the average value of $i_{dc}$?In [1]:
from IPython.display import Image
Image(filename =r'VSC_bi_7_fig_1.png', width=320)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat VSC_bi_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 VSC_bi_7_orig.in and produces a new circuit file VSC_bi_7.in, after replacing \$Vdc, \$L, etc. with values of our choice.
In [3]:
import gseim_calc as calc
s_Vdc = '400'
s_R = '10'
s_L = '0.1'
s_f_hz = "100"
f_hz = float(s_f_hz)
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("VSC_bi_7_orig.in", "VSC_bi_7.in", l)
print('VSC_bi_7.in is ready for execution')
VSC_bi_7.in is ready for execution
Execute the following cell to run GSEIM on VSC_bi_7.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("VSC_bi_7.in")
os.system('run_gseim VSC_bi_7.in')
get_lib_elements: filename gseim_aux/xbe.aux get_lib_elements: filename gseim_aux/ebe.aux Circuit: filename = VSC_bi_7.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.0933e+00 Transient simulation starts... i=0 solve_ssw_ex: ssw_iter_newton=1, rhs_ssw_norm=1.7764e-15 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 (VSC_bi_7.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on VSC_bi_7.in) creates a data file called VSC_bi_7.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("VSC_bi_7.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_BD = slv.get_index(i_slv,i_out,"v_BD")
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])
for k in range(2):
ax[k].tick_params(labelbottom=False)
ax[0].plot(t, u[:,col_IR], color=color1, linewidth=1.0, label="$i_L$")
ax[0].plot(l_IR[0], l_IR[2], color=color1, linewidth=1.0, label="$i_L^{rms}$", linestyle='--', dashes=(5,3))
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[2].plot(t, u[:,col_v_BD], color=color3, linewidth=1.0, label="$V_{BD}$")
ax[2].set_xlabel('time (msec)', fontsize=11)
for k in range(3):
ax[k].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
ax[k].set_xlim(left=0.0, right=2.0*T)
ax[k].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_7.dat average DC source current: 2.0827E-01 rms DC source current: 1.4224E+00 rms load current: 1.4224E+00 peak load current: 2.4520E+00 power absorbed by load: 2.0231E+01 power delivered by Vdc: 8.3306E+01 power delivered by VS1: -6.2595E+01 peak Idc: 2.452191 peak IL: 2.452031
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: