Switched-capacitor converter
A series-parallel switched-capacitor converter is shown in the figure. The input voltage is $50\,$V, the load resistance is $10\,k\Omega$, and the capacitors are $50\,\mu$F each with an ESR of $0.75\,\Omega$. The clock has a frequency of $50\,$kHz and a duty ratio of $50\,\%$. Determine- the output voltage
- the voltage across each capacitor
In [1]:
from IPython.display import Image
Image(filename =r'switched_cap_2_fig_1.png', width=600)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat switched_cap_2_orig.in
We now replace the strings such as \$C with the values of our choice by running the python script given below. It takes an existing circuit file switched_cap_2_orig.in and produces a new circuit file switched_cap_2.in, after replacing \$C (etc) with values of our choice.
In [3]:
import gseim_calc as calc
import numpy as np
s_C = "50u"
s_f_hz = "50e3"
s_ESR = "0.75"
s_RL = "10k"
l = [
('$C', s_C),
('$f_hz', s_f_hz),
('$ESR', s_ESR),
('$RL', s_RL),
]
calc.replace_strings_1("switched_cap_2_orig.in", "switched_cap_2.in", l)
print('switched_cap_2.in is ready for execution')
switched_cap_2.in is ready for execution
Execute the following cell to run GSEIM on controlled_rectifier_3ph_1.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("switched_cap_2.in")
os.system('run_gseim switched_cap_2.in')
Circuit: filename = switched_cap_2.in main: calling solve_sss solve_sss starting: sss_n_st: 4 solve_sss_ex: sss_iter_newton=0, rhs_sss_norm=3.1630e-04, sss_period_1_compute=2.0000e-05 solve_sss_ex: sss_iter_newton=1, rhs_sss_norm=7.5984e-16, sss_period_1_compute=2.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 (switched_cap_1.in) is created in the same directory as that used for launching Jupyter notebook. The last step (i.e., running GSEIM on switched_cap_1.in) creates data files called switched_cap_1.dat, etc. 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
f_hz = float(s_f_hz)
T = 1.0/f_hz
slv = calc.slv("switched_cap_2.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]
v_c1 = slv.get_array_double(i_slv,i_out,"v_c1",u)
v_c2 = slv.get_array_double(i_slv,i_out,"v_c2",u)
v_c3 = slv.get_array_double(i_slv,i_out,"v_c3",u)
v_c4 = slv.get_array_double(i_slv,i_out,"v_c4",u)
i_c1 = slv.get_array_double(i_slv,i_out,"i_c1",u)
i_c2 = slv.get_array_double(i_slv,i_out,"i_c2",u)
i_c3 = slv.get_array_double(i_slv,i_out,"i_c3",u)
i_c4 = slv.get_array_double(i_slv,i_out,"i_c4",u)
v_c1_avg = calc.avg_3(t, v_c1, 0.0, 2.0*T, 1.0e-4*T)
v_c2_avg = calc.avg_3(t, v_c2, 0.0, 2.0*T, 1.0e-4*T)
v_c3_avg = calc.avg_3(t, v_c3, 0.0, 2.0*T, 1.0e-4*T)
v_c4_avg = calc.avg_3(t, v_c4, 0.0, 2.0*T, 1.0e-4*T)
print('average voltage across C1:', "%11.4E"%(v_c1_avg))
print('average voltage across C2:', "%11.4E"%(v_c2_avg))
print('average voltage across C3:', "%11.4E"%(v_c3_avg))
print('average voltage across C4:', "%11.4E"%(v_c4_avg))
color1 = "blue"
color2 = "red"
color3 = "green"
color4 = "grey"
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.set_xlim(left=0.0, right=2.0*T*1e6)
ax.plot(t*1e6, v_c1, color=color1, linewidth=1.0, label="$V_{C1}$")
ax.plot(t*1e6, v_c2, color=color2, linewidth=1.0, label="$V_{C2}$")
ax.plot(t*1e6, v_c3, color=color3, linewidth=1.0, label="$V_{C3}$")
ax.plot(t*1e6, v_c4, color=color4, linewidth=1.0, label="$V_{C4}$")
plt.xlabel('time (' + r'$\mu$' + 'sec)', fontsize=11)
ax.legend(loc = 'upper right',frameon = True, fontsize = 10, title = None,
markerfirst = True, markerscale = 1.0, labelspacing = 0.5, columnspacing = 2.0,
prop = {'size' : 12},)
plt.show()
filename: switched_cap_2.dat average voltage across C1: 4.9970E+01 average voltage across C2: 4.9970E+01 average voltage across C3: 4.9970E+01 average voltage across C4: 1.9980E+02
In [6]:
import numpy as np
import matplotlib.pyplot as plt
import gseim_calc as calc
from setsize import set_size
fig, ax = plt.subplots(4, sharex=False)
plt.subplots_adjust(wspace=0, hspace=0.0)
set_size(6.5, 6, ax[0])
for i in range(4):
ax[i].set_xlim(left=0.0, right=2.0*T*1e6)
ax[i].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
ax[0].set_ylabel(r'$I_{C1}$ (A)', fontsize=12)
ax[1].set_ylabel(r'$I_{C2}$ (A)', fontsize=12)
ax[2].set_ylabel(r'$I_{C3}$ (A)', fontsize=12)
ax[3].set_ylabel(r'$I_{C4}$ (A)', fontsize=12)
for k in range(3):
ax[k].tick_params(labelbottom=False)
color1 = "blue"
ax[0].plot(t*1e6, i_c1, color=color1, linewidth=1.0)
ax[1].plot(t*1e6, i_c2, color=color2, linewidth=1.0)
ax[2].plot(t*1e6, i_c3, color=color3, linewidth=1.0)
ax[3].plot(t*1e6, i_c4, color=color4, linewidth=1.0)
ax[3].set_xlabel(r'time ($\mu$sec)', fontsize=12)
plt.show()
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.
In [ ]: