Buck-boost Converter: DCM

The periodic current (with a period of $10\,\mu$s) through the inductor of a buck-boost converter is given below. The capacitance $C$ is large so that the voltage across it is constant. Find the inductance $L$ and the load resistance $R$.
In [1]:
from IPython.display import Image
Image(filename =r'buck_boost_dcm_1_fig_1.png', width=650)
Out[1]:
No description has been provided for this image
In [2]:
# run this cell to view the circuit file.
%pycat buck_boost_dcm_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_boost_dcm_1_orig.in and produces a new circuit file buck_boost_dcm_1.in, after replacing \$L, \$C, \$R, \$D, \$f_hz with the values of our choice.

In [3]:
import gseim_calc as calc
s_Vin = '50'
s_L = '50e-6' # to be changed by user
s_C = '200e-6'
s_R = '100' #to be changed by user
s_D = '0.5'
s_f_hz = '100e3'
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_boost_dcm_1_orig.in", "buck_boost_dcm_1.in", l)
print('buck_boost_dcm_1.in is ready for execution')
buck_boost_dcm_1.in is ready for execution
Execute the following cell to run GSEIM on buck_boost_dcm_1.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("buck_boost_dcm_1.in")
os.system('run_gseim buck_boost_dcm_1.in')
Circuit: filename = buck_boost_dcm_1.in
main: i_solve = 0
main: calling solve_ssw
mat_ssw_1_ex: n_statevar: 3
Transient simulation starts...
i=0
i=1000
solve_ssw_ex: ssw_iter_newton=0, ssw_period_1_compute=2.0000e-05, rhs_ssw_norm=5.7511e+00
Transient simulation starts...
i=0
i=1000
solve_ssw_ex: ssw_iter_newton=1, ssw_period_1_compute=2.0000e-05, rhs_ssw_norm=8.6050e-01
Transient simulation starts...
i=0
i=1000
solve_ssw_ex: ssw_iter_newton=2, ssw_period_1_compute=2.0000e-05, rhs_ssw_norm=2.7616e-03
Transient simulation starts...
i=0
i=1000
solve_ssw_ex: ssw_iter_newton=3, ssw_period_1_compute=2.0000e-05, rhs_ssw_norm=5.2102e-08
Transient simulation starts...
i=0
i=1000
solve_ssw_ex: ssw_iter_newton=4, ssw_period_1_compute=2.0000e-05, rhs_ssw_norm=4.8157e-17
solve_ssw_ex: calling solve_ssw_1_ex for one more trns step
Transient simulation starts...
i=0
i=1000
solve_ssw_ex over (after trns step for output)
solve_ssw_ex ends, slv.ssw_iter_newton=4
GSEIM: Program completed.
Out[4]:
0

The circuit file (buck_boost_dcm_1.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on buck_boost_dcm_1.in) creates a data file buck_boost_dcm_1.dat in the same directory. We can now use the python code below to view the inductor current as a function of time.

In [5]:
import numpy as np
import matplotlib.pyplot as plt 
import gseim_calc as calc
from setsize import set_size

slv = calc.slv("buck_boost_dcm_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]

IL = slv.get_array_double(i_slv,i_out,"IL",u)
IS = slv.get_array_double(i_slv,i_out,"IS",u)
ID = slv.get_array_double(i_slv,i_out,"ID",u)
IC = slv.get_array_double(i_slv,i_out,"IC",u)
IR = slv.get_array_double(i_slv,i_out,"IR",u)
v_out = slv.get_array_double(i_slv,i_out,"v_out",u)
clock = slv.get_array_double(i_slv,i_out,"clock",u)
VL = slv.get_array_double(i_slv,i_out,"VL",u)

# 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_3a(t, IL, 0.0, 2.0*T, 1.0e-3*T)
l_IS = calc.avg_rms_3a(t, IS, 0.0, 2.0*T, 1.0e-3*T)
l_ID = calc.avg_rms_3a(t, ID, 0.0, 2.0*T, 1.0e-3*T)
l_IC = calc.avg_rms_3a(t, IC, 0.0, 2.0*T, 1.0e-3*T)
l_IR = calc.avg_rms_3a(t, IR, 0.0, 2.0*T, 1.0e-3*T)
l_v_out = calc.avg_rms_3a(t, v_out, 0.0, 2.0*T, 1.0e-3*T)

print('average output voltage:'  , "%11.4E"%l_v_out[0])
print('average switch current:'  , "%11.4E"%l_IS[0])
print('average diode current:'   , "%11.4E"%l_ID[0])
print('average load current:'    , "%11.4E"%l_IR[0])
print('average inductor current:', "%11.4E"%l_IL[0])
print('rms inductor current:'    , "%11.4E"%l_IL[1])

l1 = calc.min_max_1(t, IL, 0.0, 2.0*T)
IL_ptop = l1[1] - l1[0]
print('IL_ptop:', "%11.4E"%IL_ptop)

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

set_size(6.5, 10, ax[0])

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

for i in range(6):
    ax[i].tick_params(labelbottom=False)

ax[0].set_ylabel(r'clock', fontsize=12)
ax[1].set_ylabel(r'$i_L$', fontsize=12)
ax[2].set_ylabel(r'$i_C$', fontsize=12)
ax[3].set_ylabel(r'$i_D$', fontsize=12)
ax[4].set_ylabel(r'$i_S$', fontsize=12)
ax[5].set_ylabel(r'$v_o$', fontsize=12)
ax[6].set_ylabel(r'$v_L$', fontsize=12)

ax[0].set_ylim(bottom=-0.2, top=1.2)
ax[0].set_yticks([0.0, 1.0])

color1 = "blue"
color2 = "tomato"
color3 = "dodgerblue"
color4 = "olive"
color5 = "green"
color6 = "red"
color7 = "darkcyan"

ax[0].plot(t*1e3, clock, color=color1, linewidth=1.0, label="clock")

ax[1].plot(t*1e3, IL, color=color2, linewidth=1.0, label="$i_L$")
ax[1].axhline(y=l_IL[0] , color=color2, linewidth=1.0, label="$i_L^{avg}$", linestyle='--', dashes=(5,3))

ax[2].plot(t*1e3, IC, color=color3, linewidth=1.0, label="$i_C$")
ax[2].axhline(y=l_IC[0] , color=color3, linewidth=1.0, label="$i_C^{avg}$", linestyle='--', dashes=(5,3))

ax[3].plot(t*1e3, ID, color=color4, linewidth=1.0, label="$i_D$")
ax[3].axhline(y=l_ID[0] , color=color4, linewidth=1.0, label="$i_D^{avg}$", linestyle='--', dashes=(5,3))

ax[4].plot(t*1e3, IS, color=color5, linewidth=1.0, label="$i_S$")
ax[4].axhline(y=l_IS[0] , color=color5, linewidth=1.0, label="$i_S^{avg}$", linestyle='--', dashes=(5,3))

ax[5].plot(t*1e3, v_out  , color=color7, linewidth=1.0, label="$v_o$")
ax[5].axhline(y=l_v_out[0], color=color7, linewidth=1.0, label="$v_o^{avg}$", linestyle='--', dashes=(5,3))

ax[6].plot(t*1e3, VL, color=color6, linewidth=1.0, label="$v_L$")

ax[6].set_xlabel('time (ms)', fontsize=12)

for i in range(1,6):
    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: buck_boost_dcm_1.dat
average output voltage:  7.8762E+01
average switch current:  1.2512E+00
average diode current:  7.9011E-01
average load current:  7.8762E-01
average inductor current:  2.0413E+00
rms inductor current:  2.6079E+00
IL_ptop:  4.9997E+00
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 [ ]: