Push-pull converter
For the push-pull converter shown in the figure, the input voltage is $40\,$V, the output voltage is $20\,$V, and the load resistance is $2\,\Omega$. The gate signals $g_1$ and $g_2$ are shown in the figure. The magnetizing inductance as seen from the source side is $5\,$mH (for each winding). The output capacitance is $20\,\mu$F, and the filter inductance is $500\,\mu$H. Determine the following.- the transformer turn ratio
- peak voltage stress on switches $S_1$, $S_2$, and the rms values of $i_{S1}$, $i_{S2}$
- peak voltage stress on diodes $D_1$, $D_2$, and the average values of $i_{D1}$, $i_{D2}$
- ripple frequency of the inductor current
In [1]:
from IPython.display import Image
Image(filename =r'push_pull_1_fig_1.png', width=750)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat push_pull_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 push_pull_1_orig.in and produces a new circuit file push_pull_1.in, after replacing \$Vdc, \$L, etc. with values of our choice.
In [3]:
import gseim_calc as calc
s_Vdc = "40"
s_L = "500e-6"
s_R = "2"
s_C = "20e-6"
s_n = "2.0" # to be changed by user
f_hz = 50.0e3
T = 1/f_hz
s_Tend = "3e-3"
Tend = float(s_Tend)
T1 = Tend - 2.0*T
s_T1 = ("%11.4E"%(T1)).strip()
l = [
('$Vdc', s_Vdc),
('$L', s_L),
('$R', s_R),
('$C', s_C),
('$n', s_n),
('$Tend', s_Tend),
('$T1', s_T1),
]
calc.replace_strings_1("push_pull_1_orig.in", "push_pull_1.in", l)
print('push_pull_1.in is ready for execution')
push_pull_1.in is ready for execution
Execute the following cell to run GSEIM on push_pull_1.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("push_pull_1.in")
os.system('run_gseim push_pull_1.in')
get_lib_elements: filename gseim_aux/xbe.aux get_lib_elements: filename gseim_aux/ebe.aux Circuit: filename = push_pull_1.in main: i_solve = 0 main: calling solve_trns Transient simulation starts... i=0 i=10000 GSEIM: Program completed.
Out[4]:
0
The circuit file (push_pull_1.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on push_pull_1.in) creates a data file called push_pull_1.dat in 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("push_pull_1.in")
i_slv = 0
i_out = 0
filename = slv.l_filename_all[i_slv][i_out]
print('filename:', filename)
u = np.loadtxt(filename)
ta = u[:, 0]
t = ta - ta[0]
col_v_out = slv.get_index(i_slv,i_out,"v_out")
col_IL = slv.get_index(i_slv,i_out,"IL" )
col_VD1 = slv.get_index(i_slv,i_out,"VD1" )
col_VD2 = slv.get_index(i_slv,i_out,"VD2" )
col_VS1 = slv.get_index(i_slv,i_out,"VS1" )
col_VS2 = slv.get_index(i_slv,i_out,"VS2" )
i_out = 1
filename = slv.l_filename_all[i_slv][i_out]
print('filename:', filename)
u1 = np.loadtxt(filename)
t1a = u1[:, 0]
t1 = t1a - t1a[0]
col_ID1 = slv.get_index(i_slv,i_out,"ID1")
col_ID2 = slv.get_index(i_slv,i_out,"ID2")
col_IS1 = slv.get_index(i_slv,i_out,"IS1")
col_IS2 = slv.get_index(i_slv,i_out,"IS2")
# since we have stored two cycles, we need to divide the last time point
# by 2 to get the period:
T = t[-1]/2
max_VD1 = -min(u[:,col_VD1])
max_VD2 = -min(u[:,col_VD2])
max_VS1 = max(u[:,col_VS1])
max_VS2 = max(u[:,col_VS2])
print('max stress on D1:', "%11.4E"%(max_VD1), 'V')
print('max stress on D2:', "%11.4E"%(max_VD2), 'V')
print('max stress on S1:', "%11.4E"%(max_VS1), 'V')
print('max stress on S2:', "%11.4E"%(max_VS2), 'V')
l_ID1 = calc.avg_rms_2(t1, u1[:,col_ID1], 0.0, 2.0*T, 1.0e-3*T)
l_ID2 = calc.avg_rms_2(t1, u1[:,col_ID2], 0.0, 2.0*T, 1.0e-3*T)
l_IS1 = calc.avg_rms_2(t1, u1[:,col_IS1], 0.0, 2.0*T, 1.0e-3*T)
l_IS2 = calc.avg_rms_2(t1, u1[:,col_IS2], 0.0, 2.0*T, 1.0e-3*T)
print('average ID1:', "%11.4E"%l_ID1[1][0], 'A')
print('average ID2:', "%11.4E"%l_ID2[1][0], 'A')
print('rms ID1:' , "%11.4E"%l_ID1[2][0], 'A')
print('rms ID2:' , "%11.4E"%l_ID2[2][0], 'A')
print('average IS1:', "%11.4E"%l_IS1[1][0], 'A')
print('average IS2:', "%11.4E"%l_IS2[1][0], 'A')
print('rms IS1:' , "%11.4E"%l_IS1[2][0], 'A')
print('rms IS2:' , "%11.4E"%l_IS2[2][0], 'A')
color1='green'
color2='crimson'
color3='goldenrod'
color4='blue'
color5='cornflowerblue'
color6='red'
fig, ax = plt.subplots(5, sharex=False)
plt.subplots_adjust(wspace=0, hspace=0.0)
set_size(7, 8, ax[0])
for i in range(5):
ax[i].set_xlim(left=0, right=2.0*T*1e6)
ax[i].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
ax[0].plot(t*1e6, u[:,col_v_out], color=color1, linewidth=1.0, label="$V_o$")
ax[1].plot(t*1e6, u[:,col_VD1 ], color=color2, linewidth=1.0, label="$V_{D1}$")
ax[2].plot(t*1e6, u[:,col_VD2 ], color=color3, linewidth=1.0, label="$V_{D2}$")
ax[3].plot(t*1e6, u[:,col_VS1 ], color=color4, linewidth=1.0, label="$V_{S1}$")
ax[4].plot(t*1e6, u[:,col_VS2 ], color=color5, linewidth=1.0, label="$V_{S2}$")
ax[0].set_ylabel(r'$V_o$' , fontsize=14)
ax[1].set_ylabel(r'$V_{D1}$', fontsize=14)
ax[2].set_ylabel(r'$V_{D2}$', fontsize=14)
ax[3].set_ylabel(r'$V_{S1}$', fontsize=14)
ax[4].set_ylabel(r'$V_{S2}$', fontsize=14)
ax[4].set_xlabel('time (' + r'$\mu$' + 'sec)', fontsize=14)
#ax[0].legend(loc = 'lower right',frameon = True, fontsize = 10, title = None,
# markerfirst = True, markerscale = 1.0, labelspacing = 0.5, columnspacing = 2.0,
# prop = {'size' : 12},)
for i in range(4):
ax[i].tick_params(labelbottom=False)
#plt.tight_layout()
plt.show()
filename: push_pull_1_1.dat filename: push_pull_1_2.dat max stress on D1: 1.5986E+02 V max stress on D2: 1.5986E+02 V max stress on S1: 7.9968E+01 V max stress on S2: 7.9968E+01 V average ID1: 7.9928E+00 A average ID2: 7.9892E+00 A rms ID1: 9.4568E+00 A rms ID2: 9.4538E+00 A average IS1: 6.3889E+00 A average IS2: 6.3960E+00 A rms IS1: 1.4291E+01 A rms IS2: 1.4299E+01 A
In [6]:
import numpy as np
import matplotlib.pyplot as plt
import gseim_calc as calc
from setsize import set_size
slv = calc.slv("push_pull_1.in")
i_slv = 0
i_out = 0
filename = slv.l_filename_all[i_slv][i_out]
print('filename:', filename)
u = np.loadtxt(filename)
ta = u[:, 0]
t = ta - ta[0]
col_IL = slv.get_index(i_slv,i_out,"IL" )
i_out = 1
filename = slv.l_filename_all[i_slv][i_out]
print('filename:', filename)
u1 = np.loadtxt(filename)
t1a = u1[:, 0]
t1 = t1a - t1a[0]
col_ID1 = slv.get_index(i_slv,i_out,"ID1")
col_ID2 = slv.get_index(i_slv,i_out,"ID2")
col_IS1 = slv.get_index(i_slv,i_out,"IS1")
col_IS2 = slv.get_index(i_slv,i_out,"IS2")
# since we have stored two cycles, we need to divide the last time point
# by 2 to get the period:
T = t[-1]/2
color1='green'
color2='crimson'
color3='goldenrod'
color4='blue'
color5='red'
fig, ax = plt.subplots(5, sharex=False)
plt.subplots_adjust(wspace=0, hspace=0.0)
set_size(7, 8, ax[0])
for i in range(5):
ax[i].set_xlim(left=0, right=2.0*T*1e6)
ax[i].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
ax[0].plot(t*1e6, u[:,col_IL ], color=color1, linewidth=1.0, label="$i_L$")
ax[1].plot(t1*1e6, u1[:,col_ID1], color=color2, linewidth=1.0, label="$i_{D1}$")
ax[2].plot(t1*1e6, u1[:,col_ID2], color=color3, linewidth=1.0, label="$i_{D2}$")
ax[3].plot(t1*1e6, u1[:,col_IS1], color=color4, linewidth=1.0, label="$i_{S1}$")
ax[4].plot(t1*1e6, u1[:,col_IS2], color=color5, linewidth=1.0, label="$i_{S2}$")
ax[0].set_ylabel(r'$i_L$' , fontsize=14)
ax[1].set_ylabel(r'$i_{D1}$', fontsize=14)
ax[2].set_ylabel(r'$i_{D2}$', fontsize=14)
ax[3].set_ylabel(r'$i_{S1}$', fontsize=14)
ax[4].set_ylabel(r'$i_{S2}$', fontsize=14)
ax[4].set_xlabel('time (' + r'$\mu$' + 'sec)', fontsize=14)
#ax[0].legend(loc = 'lower right',frameon = True, fontsize = 10, title = None,
# markerfirst = True, markerscale = 1.0, labelspacing = 0.5, columnspacing = 2.0,
# prop = {'size' : 12},)
for i in range(4):
ax[i].tick_params(labelbottom=False)
#plt.tight_layout()
plt.show()
filename: push_pull_1_1.dat filename: push_pull_1_2.dat
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.