1-phase rectifier
In the circuit given below, $I_S=10\,$A, $v_a=100\cos(\omega t)$ and $v_b=100\cos(\omega t-90^\circ)$. Determine- the peak-to-peak ripple in $v_o$
- the average value of $v_o$
In [1]:
from IPython.display import Image
Image(filename =r'rectifier_1ph_12_fig_1.png', width=320)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat rectifier_1ph_12_orig.in
Execute the following cell to run GSEIM on rectifier_1ph_12_orig.in.
In [3]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("rectifier_1ph_12_orig.in")
os.system('run_gseim rectifier_1ph_12_orig.in')
get_lib_elements: filename gseim_aux/xbe.aux get_lib_elements: filename gseim_aux/ebe.aux Circuit: filename = rectifier_1ph_12_orig.in Circuit: n_xbeu_vr = 0 Circuit: n_ebeu_nd = 7 main: i_solve = 0 main: calling solve_trns Transient simulation starts... i=0 i=1000 i=2000 GSEIM: Program completed.
Out[3]:
0
The last step (i.e., running GSEIM on rectifier_1ph_12_orig.in) creates a data file called rectifier_1ph_12.dat in the directory from which Jupyter was launched. We can now use the python code below to compute/plot the various quantities of interest.
In [4]:
import numpy as np
import matplotlib.pyplot as plt
import gseim_calc as calc
from setsize import set_size
f_hz = 50.0
T = 1.0/f_hz
slv = calc.slv("rectifier_1ph_12_orig.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]
col_v_sa = slv.get_index(i_slv,i_out,"v_sa")
col_v_sb = slv.get_index(i_slv,i_out,"v_sb")
col_v_o = slv.get_index(i_slv,i_out,"v_o")
l_v_o = calc.avg_rms_2(t, u[:,col_v_o], 0.0, 2.0*T, 1.0e-5*T)
t_v_o = np.array(l_v_o[0])
print('average value of v_o:', "%11.4E"%(l_v_o[1][0]))
l1 = calc.min_max_1(t, u[:,col_v_o], 0.0, 2.0*T)
v_o_ptop = l1[1] - l1[0]
print('ripple in v_o:', "%11.4E"%v_o_ptop)
color1 = 'blue'
color2 = 'green'
color3 = 'red'
fig, ax = plt.subplots(2, sharex=False)
plt.subplots_adjust(wspace=0, hspace=0.0)
set_size(5.5, 4, ax[0])
for i in range(2):
ax[i].set_xlim(left=0.0, right=2.0*T*1e3)
ax[i].grid(color='#CCCCCC', linestyle='solid', linewidth=0.5)
ax[0].set_ylabel(r'$v_s$' , fontsize=12)
ax[1].set_ylabel(r'$v_o$' , fontsize=12)
ax[0].tick_params(labelbottom=False)
ax[0].plot(t*1e3, u[:,col_v_sa], color=color1, linewidth=1.0, label="$v_{sa}$")
ax[0].plot(t*1e3, u[:,col_v_sb], color=color2, linewidth=1.0, label="$v_{sb}$")
ax[1].plot(t*1e3, u[:,col_v_o] , color=color3, linewidth=1.0, label="$v_o$")
ax[1].plot(t_v_o*1e3, l_v_o[1], color=color3, linewidth=1.0, label="$v_o^{avg}$", linestyle='--', dashes=(5,3))
ax[1].set_xlabel('time (msec)', fontsize=11)
for i in range(2):
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: rectifier_1ph_12.dat average value of v_o: 1.2728E+02 ripple in v_o: 4.1411E+01
This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.