Buck Converter: CCM
The buck converter given below is operating in continuous conduction mode with a switching frequency of $10\,$kHz. The converter has the following specifications: $V_{in}=100\,V$ , $V_{out}=25\,V$, $R=2.5\,\Omega$. The peak-to-peak ripple in inductor current is $20\,\%$ of the average current through it and the peak-to-peak ripple in output capacitor voltage is $0.1\,$V. Determine- duty cycle
- $L$ and $C$
- peak and average inductor current
- RMS current through switch, diode, inductor, and capacitor
- average current through switch, diode, inductor, and capacitor
from IPython.display import Image
Image(filename =r'buck_ccm_1_fig_1.png', width=320)
# run this cell to view the circuit file.
%pycat buck_ccm_1_orig.in
We now replace the strings \$Vin, \$L, \$C, \$R, \$D, \$f_hz with the values of our choice by running the python script given below. It takes an existing circuit file buck_ccm_1_orig.in and produces a new circuit file buck_ccm_1.in, after replacing \$L, \$C, \$R, \$D, \$f_hz with the values of our choice.
import gseim_calc as calc
s_Vin = '100'
s_L = '0.6e-3' # to be changed by user
s_C = '50e-6' # to be changed by user
s_R = '2.5'
s_D = '0.4' # to be changed by user
s_f_hz = '10e3'
l = [
('$Vin', s_Vin),
('$L', s_L),
('$C', s_C),
('$R', s_R),
('$D', s_D),
('$f_hz', s_f_hz)
]
calc.replace_strings_1("buck_ccm_1_orig.in", "buck_ccm_1.in", l)
print('buck_ccm_1.in is ready for execution')
buck_ccm_1.in is ready for execution
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("buck_ccm_1.in")
os.system('run_gseim buck_ccm_1.in')
get_lib_elements: filename gseim_aux/xbe.aux get_lib_elements: filename gseim_aux/ebe.aux Circuit: filename = buck_ccm_1.in Circuit: n_xbeu_vr = 1 Circuit: n_ebeu_nd = 4 main: i_solve = 0 ssw_allocate_1 (2): n_statevar=3 main: calling solve_trns mat_ssw_1_ex: n_statevar: 3 mat_ssw_1_e0: cct.n_ebeu: 6 Transient simulation starts... i=0 i=1000 solve_ssw_ex: ssw_iter_newton=0, rhs_ssw_norm=6.1088e+00 Transient simulation starts... i=0 i=1000 solve_ssw_ex: ssw_iter_newton=1, rhs_ssw_norm=2.9742e-13 solve_ssw_ex: calling solve_ssw_1_ex for one more trns step Transient simulation starts... i=0 i=1000 solve_ssw_1_ex over (after trns step for output) solve_ssw_ex ends, slv.ssw_iter_newton=1 GSEIM: Program completed.
0
The circuit file (buck_ccm_1.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on buck_ccm_1.in) creates a data file buck_ccm_1.dat in the same directory. We can now use the python code below to view the inductor current as a function of time.
import numpy as np
import matplotlib.pyplot as plt
import gseim_calc as calc
from setsize import set_size
slv = calc.slv("buck_ccm_1.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 = t1*1e6 # convert time to micro-seconds
col_IL = slv.get_index(i_slv,i_out,"IL")
col_IS = slv.get_index(i_slv,i_out,"IS")
col_ID = slv.get_index(i_slv,i_out,"ID")
col_IC = slv.get_index(i_slv,i_out,"IC")
col_v_out = slv.get_index(i_slv,i_out,"v_out")
col_clock = slv.get_index(i_slv,i_out,"clock")
# 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_IL = calc.avg_rms_2(t, u[:,col_IL], 0.0, 2.0*T, 1.0e-3*T)
l_IS = calc.avg_rms_2(t, u[:,col_IS], 0.0, 2.0*T, 1.0e-3*T)
l_ID = calc.avg_rms_2(t, u[:,col_ID], 0.0, 2.0*T, 1.0e-3*T)
l_IC = calc.avg_rms_2(t, u[:,col_IC], 0.0, 2.0*T, 1.0e-3*T)
l_v_out = calc.avg_rms_2(t, u[:,col_v_out], 0.0, 2.0*T, 1.0e-3*T)
print('average output voltage:', "%11.4E"%l_v_out[1][0])
print('average input current:', "%11.4E"%l_IS[1][0])
print('average load current:', "%11.4E"%l_IL[1][0])
color1='green'
color2='crimson'
color3='goldenrod'
color4='blue'
fig, ax = plt.subplots()
plt.subplots_adjust(wspace=0, hspace=0.0)
set_size(4, 2.5, ax)
plt.grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
ax.plot(t, u[:,col_IL], color=color1, linewidth=1.0, label="$I_L$")
ax.plot(l_IL[0], l_IL[1], color=color1, linewidth=1.0, label="$I_L^{avg}$", linestyle='--', dashes=(5,3))
ax.plot(l_IL[0], l_IL[2], color=color1, linewidth=1.0, label="$I_L^{rms}$", linestyle='-.')
plt.xlabel('time (' + r'$\mu$' + 'sec)', fontsize=11)
ax.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: buck_ccm_1.dat average output voltage: 3.9982E+01 average input current: 6.3976E+00 average load current: 1.5993E+01
On the output file produced by GSEIM (in this case, buck_ccm_1.dat), we can do some post-processing to obtain average and rms values, for example. For this purpose, a python module gseim_calc.py has been included in the directory from which you launched Jupyter. Run the following python script to obtain the quantities of interest listed in the question.
import gseim_calc as calc
import numpy as np
slv = calc.slv("buck_ccm_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_IL = slv.get_index(i_slv,i_out,"IL")
col_IS = slv.get_index(i_slv,i_out,"IS")
col_ID = slv.get_index(i_slv,i_out,"ID")
col_IC = slv.get_index(i_slv,i_out,"IC")
col_v_out = slv.get_index(i_slv,i_out,"v_out")
col_clock = slv.get_index(i_slv,i_out,"clock")
T = t[-1]/2
l_IL = calc.avg_rms_2(t, u[:,col_IL], 0.0, 2.0*T, 1.0e-3*T)
l_IS = calc.avg_rms_2(t, u[:,col_IS], 0.0, 2.0*T, 1.0e-3*T)
l_ID = calc.avg_rms_2(t, u[:,col_ID], 0.0, 2.0*T, 1.0e-3*T)
l_IC = calc.avg_rms_2(t, u[:,col_IC], 0.0, 2.0*T, 1.0e-3*T)
l_v_out = calc.avg_rms_2(t, u[:,col_v_out], 0.0, 2.0*T, 1.0e-3*T)
t_start = 0.0
t_end = 2.0*T
l1 = calc.min_max_1(t, u[:,col_IL], t_start, t_end)
IL_ptop = l1[1] - l1[0]
print('IL_ptop:', "%11.4E"%IL_ptop)
print('IL_peak:', "%11.4E"%l1[1])
l1a = calc.min_max_1(t, u[:,col_v_out], t_start, t_end)
VC_ptop = l1a[1] - l1a[0]
print('VC_ptop:', "%11.4E"%VC_ptop)
IL_rms = l_IL[2][0]
print('IL_rms:', "%11.4E"%IL_rms)
IS_rms = l_IS[2][0]
print('IS_rms:', "%11.4E"%IS_rms)
ID_rms = l_ID[2][0]
print('ID_rms:', "%11.4E"%ID_rms)
IC_rms = l_IC[2][0]
print('IC_rms:', "%11.4E"%IC_rms)
Vout_avg = l_v_out[1][0]
print('Vout_avg:', "%11.4E"%Vout_avg)
filename: buck_ccm_1.dat IL_ptop: 4.0266E+00 IL_peak: 1.8007E+01 VC_ptop: 1.0012E+00 IL_rms: 1.6035E+01 IS_rms: 1.0142E+01 ID_rms: 1.2420E+01 IC_rms: 1.1541E+00 Vout_avg: 3.9982E+01
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.