Two-switch forward converter
In the two-switch forward converter shown in the figure, the duty ratio is 0.4, and the switching frequency is $20\,$kHz. The input voltage of the converter is $100\,$V, and it is connected to a load resistance of $4\,\Omega$. The output voltage of the converter is $20\,$V. The magnetizing inductance of the transformer as seen from the source side is $5\,$mH. The output capacitance is $20\,\mu$F, and the filter inductance is $500\,\mu$H.- Determine the turns ratio of the transformer.
- Determine the peak magnetizing current of the transformer.
- What is the duration of conduction for $D_1$ and $D_2$?
- Plot the current drawn from the DC source and determine its peak.
In [1]:
from IPython.display import Image
Image(filename =r'forward_3_fig_1.png', width=400)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat forward_3_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 forward_3_orig.in and produces a new circuit file forward_3.in, after replacing \$Vdc, \$L, etc. with values of our choice.
In [3]:
import gseim_calc as calc
s_Vdc = "100"
s_Lm = "5e-3"
s_L = "500e-6"
s_R = "4"
s_C = "20e-6"
s_N1 = "1"
s_N2 = "0.5" # to be entered by user
f_hz = 20.0e3
T = 1/f_hz
s_Tend = "4e-3"
Tend = float(s_Tend)
T1 = Tend - 2.0*T
s_T1 = ("%11.4E"%(T1)).strip()
l = [
('$Vdc', s_Vdc),
('$Lm', s_Lm),
('$L', s_L),
('$R', s_R),
('$C', s_C),
('$N1', s_N1),
('$N2', s_N2),
('$Tend', s_Tend),
('$T1', s_T1),
]
calc.replace_strings_1("forward_3_orig.in", "forward_3.in", l)
print('forward_3.in is ready for execution')
forward_3.in is ready for execution
Execute the following cell to run GSEIM on forward_3.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("forward_3.in")
os.system('run_gseim forward_3.in')
get_lib_elements: filename gseim_aux/xbe.aux get_lib_elements: filename gseim_aux/ebe.aux Circuit: filename = forward_3.in main: i_solve = 0 main: calling solve_trns Transient simulation starts... i=0 i=10000 i=20000 GSEIM: Program completed.
Out[4]:
0
The circuit file (forward_3.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on forward_3.in) creates a data files called forward_3.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("forward_3.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_ILm = slv.get_index(i_slv,i_out,"ILm" )
col_ID1 = slv.get_index(i_slv,i_out,"ID1" )
col_ID2 = slv.get_index(i_slv,i_out,"ID2" )
col_IVs = slv.get_index(i_slv,i_out,"IVs" )
# 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_ILm_1 = calc.min_max_1(t, u[:,col_ILm], 0.0, 2.0*T)
print('maximum value of ILm:', "%11.4E"%l_ILm_1[1], " A")
l_IVs_1 = calc.min_max_1(t, u[:,col_IVs], 0.0, 2.0*T)
print('maximum value of IVs:', "%11.4E"%l_IVs_1[1], " A")
ndiv = 5000
n_ID1 = 0
n_ID2 = 0
delt_ID1, ID1p = calc.interp_linear_1(t, u[:,col_ID1], ndiv)
delt_ID2, ID2p = calc.interp_linear_1(t, u[:,col_ID2], ndiv)
for k in range(ndiv):
if (ID1p[k] > 0): n_ID1 += 1
if (ID2p[k] > 0): n_ID2 += 1
print('duration of conduction for D1 in one cycle:',
"%11.4E"%(1.0e6*float(n_ID1)*delt_ID1/(2.0)), 'micro seconds.')
print('duration of conduction for D2 in one cycle:',
"%11.4E"%(1.0e6*float(n_ID2)*delt_ID2/(2.0)), 'micro seconds.')
color1='green'
color2='crimson'
color3='goldenrod'
color4='blue'
color5='cornflowerblue'
color6='red'
fig, ax = plt.subplots(6, sharex=False)
plt.subplots_adjust(wspace=0, hspace=0.0)
set_size(7, 7, ax[0])
for i in range(6):
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(t*1e6, u[:,col_IVs ], color=color2, linewidth=1.0, label="$i_{Vs}$")
ax[2].plot(t*1e6, u[:,col_ID1 ], color=color3, linewidth=1.0, label="$i_{D1}$")
ax[3].plot(t*1e6, u[:,col_ID2 ], color=color4, linewidth=1.0, label="$i_{D2}$")
ax[4].plot(t*1e6, u[:,col_v_out], color=color5, linewidth=1.0, label="$V_o$")
ax[5].plot(t*1e6, u[:,col_ILm ], color=color6, linewidth=1.0, label="$i_{Lm}$")
ax[0].set_ylabel(r'$i_L$' , fontsize=14)
ax[1].set_ylabel(r'$i_{Vs}$', fontsize=14)
ax[2].set_ylabel(r'$i_{D1}$', fontsize=14)
ax[3].set_ylabel(r'$i_{D2}$', fontsize=14)
ax[4].set_ylabel(r'$V_o$' , fontsize=14)
ax[5].set_ylabel(r'$i_{Lm}$', fontsize=14)
ax[5].set_xlabel('time (' + r'$\mu$' + 'sec)', fontsize=14)
for i in range(5):
ax[i].tick_params(labelbottom=False)
#plt.tight_layout()
plt.show()
filename: forward_3.dat maximum value of ILm: 4.0000E-01 A maximum value of IVs: 3.2008E+00 A duration of conduction for D1 in one cycle: 1.9998E+01 micro seconds. duration of conduction for D2 in one cycle: 1.9998E+01 micro seconds.
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.