Flyback converter
The flyback converter shown in the figure has an input voltage of $20\,$V and an output voltage of $40\,$V. The switching frequency of the converter is $50\,$kHz. The flyback transformer is represented using an ideal transformer with a magnetizing inductance $L_m = 100\,\mu$H. The turns ratio of the transformer is 1:4, the load resistance is $10\,\Omega$, and the output capacitance is $100\,\mu$F.- What is the duty cycle of the converter?
- Plot the current through $L_m$, and determine the peak, rms, and average values.
- What is the peak-to-peak ripple in the output voltage?
- Plot the currents through the switch, diode, and capacitor.
In [1]:
from IPython.display import Image
Image(filename =r'flyback_1_fig_1.png', width=320)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat flyback_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 flyback_1_orig.in and produces a new circuit file flyback_1.in, after replacing \$Vdc, \$L, etc. with values of our choice.
In [3]:
import gseim_calc as calc
s_D = "0.25" # to be changed by user
s_Vdc = "20"
s_L = "100e-6"
s_R = "10"
s_C = "100e-6"
s_N1 = "1"
s_N2 = "4"
s_f_hz = "50e3"
l = [
('$D', s_D),
('$Vdc', s_Vdc),
('$L', s_L),
('$R', s_R),
('$C', s_C),
('$N1', s_N1),
('$N2', s_N2),
('$f_hz', s_f_hz),
]
calc.replace_strings_1("flyback_1_orig.in", "flyback_1.in", l)
print('flyback_1.in is ready for execution')
flyback_1.in is ready for execution
Execute the following cell to run GSEIM on flyback_1.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("flyback_1.in")
os.system('run_gseim flyback_1.in')
Circuit: filename = flyback_1.in main: calling solve_sss solve_sss starting: sss_n_st: 2 solve_sss_ex: sss_iter_newton=0, rhs_sss_norm=1.4117e+00, sss_period_1_compute=4.0000e-05 solve_sss_ex: sss_iter_newton=1, rhs_sss_norm=8.1285e-05, sss_period_1_compute=4.0000e-05 solve_sss_ex: sss_iter_newton=2, rhs_sss_norm=1.5046e-06, sss_period_1_compute=4.0000e-05 solve_sss_ex: sss_iter_newton=3, rhs_sss_norm=1.8767e-10, sss_period_1_compute=4.0000e-05 solve_sss_ex: sss_iter_newton=4, rhs_sss_norm=1.0966e-12, sss_period_1_compute=4.0000e-05 solve_sss_ex: calling sss_solve_trns_ex for one more trns step Transient simulation starts... i=0 GSEIM: Program completed.
Out[4]:
0
The circuit file (flyback_1.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on flyback_1.in) creates a data file called flyback_1.dat in the same directory. We can now use the python code below to compute/plot the various quantities of interest.
In [5]:
calc.print_rms(
infile='flyback_1.in', i_slv=0, i_out=0,
var_name="ILm", t_start=0.0, t_end=40.0e-6,
s_format="%11.4E", s1="rms inductor current:", s2="Amp")
calc.print_avg(
infile='flyback_1.in', i_slv=0, i_out=0,
var_name="ILm", t_start=0.0, t_end=40.0e-6,
s_format="%11.4E", s1="average inductor current:", s2="Amp")
calc.print_max(
infile='flyback_1.in', i_slv=0, i_out=0,
var_name="ILm", t_start=0.0, t_end=40.0e-6,
s_format="%11.4E", s1="peak inductor current:", s2="Amp")
calc.print_ptop(
infile='flyback_1.in', i_slv=0, i_out=0,
var_name="v_out", t_start=0.0, t_end=40.0e-6,
s_format="%11.4E", s1="peak-to-peak ripple in Vo:", s2="V")
n_plots = 5
l_n_curves = [1, 1, 1, 1, 1]
plot_multi = calc.gseim_plot_multi(n_plots, l_n_curves)
plot_multi.plot_all[0].l_plots[0].i_slv = 0
plot_multi.plot_all[0].l_plots[0].i_out = 0
plot_multi.plot_all[0].l_plots[0].var_name = "ILm"
plot_multi.plot_all[0].l_plots[0].plot_type = "X-time"
plot_multi.plot_all[0].l_plots[0].color = "green"
plot_multi.plot_all[1].l_plots[0].i_slv = 0
plot_multi.plot_all[1].l_plots[0].i_out = 0
plot_multi.plot_all[1].l_plots[0].var_name = "IC"
plot_multi.plot_all[1].l_plots[0].plot_type = "X-time"
plot_multi.plot_all[1].l_plots[0].color = "crimson"
plot_multi.plot_all[2].l_plots[0].i_slv = 0
plot_multi.plot_all[2].l_plots[0].i_out = 0
plot_multi.plot_all[2].l_plots[0].var_name = "IS"
plot_multi.plot_all[2].l_plots[0].plot_type = "X-time"
plot_multi.plot_all[2].l_plots[0].color = "goldenrod"
plot_multi.plot_all[3].l_plots[0].i_slv = 0
plot_multi.plot_all[3].l_plots[0].i_out = 0
plot_multi.plot_all[3].l_plots[0].var_name = "ID"
plot_multi.plot_all[3].l_plots[0].plot_type = "X-time"
plot_multi.plot_all[3].l_plots[0].color = "blue"
plot_multi.plot_all[4].l_plots[0].i_slv = 0
plot_multi.plot_all[4].l_plots[0].i_out = 0
plot_multi.plot_all[4].l_plots[0].var_name = "v_out"
plot_multi.plot_all[4].l_plots[0].plot_type = "X-time"
plot_multi.plot_all[4].l_plots[0].color = "cornflowerblue"
plot_multi.plot_all[0].y_label = r'$i_{Lm}$'
plot_multi.plot_all[1].y_label = r'$i_C$'
plot_multi.plot_all[2].y_label = r'$i_S$'
plot_multi.plot_all[3].y_label = r'$i_D$'
plot_multi.plot_all[4].y_label = r'$V_{out}$'
calc.plot_multi_time(
infile='flyback_1.in',
t_mult=1e6,
x_size=7.0,
y_size=7.0,
x_label='time (' + r'$\mu$' + 'sec)',
label_font_size=11,
legend_fontsize=10,
t_start=0.0,
t_end=40.0e-6,
t_offset=0.0,
plot_multi=plot_multi)
rms inductor current: 1.4224E+01 Amp average inductor current: 1.4221E+01 Amp peak inductor current: 1.4720E+01 Amp peak-to-peak ripple in Vo: 1.3329E-01 V filename: flyback_1.dat
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: